+ Reply to Thread
Results 1 to 8 of 8

Thread: centering of field

  1. #1
    Guest.Visitor Guest

    Default centering of field

    ExampleIf a field is define as 30 alpha(field named=#asd) , and that field Data was stored like----'fees ' and you wanted to print it like--' fees 'or pretty closed to the center, how would this be done. I try Eval xxxx = %trim(#asd) #asd = the name of the field within a file xxxx = the name you want to print out

  2. #2
    Guest.Visitor Guest

    Default centering of field

    Hi When I tried to use the MemCpy API, I ended up with the compiler error stating "Definition not found for symbol 'MemCpy'". Which library should I add to the library list to enable the functionality of this API. I have least idea about this; Could you please provide some more explanation on this. Bala.

  3. #3
    Guest.Visitor Guest

    Default centering of field

    On Tuesday, June 29, 1999, 05:00 AM, mike7 wrote: Example If a field is define as 30 alpha(field named=#asd) , and that field Data was stored like----'fees..........................' (. = blank) and you wanted to print it like--'.............fees.............' or pretty closed to the center, how would this be done. I try Eval xxxx = %trim(#asd) #asd = the name of the field within a file xxxx = the name you want to print out Define blanks as a field or constant at least half as long as the name you want to print out.
     C eval xxxx = %subst(blanks:1: C %inth((%size(xxxx)- C -%len(%trim(#asd)))/2)) C + %triml(#asd) 
    That's pretty ugly, though. If you do a lot of centering, here's a procedure to center data for an output field up to 100 characters long. Call it like this:
     C eval xxxx = center(%trim(#asd) : %size(xxxx)) 
     p center b D center pi 100a varying D data 100a varying const D result_len 10u 0 value D blanks s 100a inz(*blanks) D num_blanks s 10u 0 C eval(h) num_blanks = (result_len - %len(data))/2 C return %subst(blanks : 1 : num_blanks) C + data C + %subst(blanks : 1 : num_blanks) p center e 
    Barbara Morris, IBM Toronto Lab, RPG Compiler Development

  4. #4
    Guest.Visitor Guest

    Default centering of field

    Centering may be accomplished using one EVAL statement, but for clarity I have broken it down here to multiple steps.

    These are temporary work fields

    D w_Length S 3 0

    D w_Position S 3 0

    Determine the length of the input field without leading or trailing blanks.

    C eval w_Length = %LEN(%TRIM(In_Fld30)) Determine the center postion for placing the input field into the output field. By using the length of the output field for this calculation, you may center fields with different lengths. * Note the "+1" at the end of this calculation, this is to guarantee that an error will not occur when the %subst in the next line is executed.

    C eval _Position=(%LEN(Out_Fld30)-w_Length)/2)+1 Now move the input field to the output field starting at the calculated center. C eval %subst(Out_Fld30:w_Center) = In_Fld30

  5. #5
    Guest.Visitor Guest

    Default centering of field

    Oh yea, one thing i left out is to clear the output field beforeexecuting the centering routine.

  6. #6
    Guest.Visitor Guest

    Default centering of field

    Mine is very similar, it's a program to call that I pass the string and the length of the field I'm centering it in...
     d Arr s 1 Dim(80) d Field s 80 d I s 2 0 d Length s 2 d Length# s 2 0 d Text s 80 Varying c *entry plist c parm Field c parm Length c move Length Length# c eval Text = %trim(Field) c eval Field = *blanks c eval Length = *blanks c eval I = ((Length# - %len(%trim(Text))) /2) +1) c movea Text Arr(I) c movea Arr Field c eval *inlr = *on 
    mhaston@scottgas.com">M. Haston@Scott Specialty Gases

  7. #7
    Guest.Visitor Guest

    Default centering of field

    On Tuesday, June 29, 1999, 07:48 AM, chitra wrote: Hi When I tried to use the MemCpy API, I ended up with the compiler error stating "Definition not found for symbol 'MemCpy'". Which library should I add to the library list to enable the functionality of this API. I have least idea about this; Could you please provide some more explanation on this. Bala. Bala, Specify binding directory qc2le on your compile and you should be fine. David Morris

  8. #8
    Guest.Visitor Guest

    Default centering of field

    Hi David, I tried Memcpy. But still I am getting the 'Decimal Data Error'. The program which I have written reads the data from one file (for which the layout is known only at the run time) and it writes the data into another file whose layout is also unknown. For this, I am using dynamic SQL which forms the SELECT Statement at run time. By using a cursor, all the records are fetched from SQLDA (Data Structure which contains SQLDATA - Pointer as a subfield) and an INSERT statement is formed at run time. The problem is with fetching the data from SQLDATA if it contains a packed data. I will be knowing the length of the data at runtime only. Even if I use Memcpy, I should declare a varaiable statically with the exact length of the data . I have given the Memcpy line that I have used in my program for your reference so that you can give some suggestions. Thanks for your support Bala Note : CALLP MemCpy(%ADDR(WVNum):SQLDATA:%size(WVNUM)) For example assume SQLDATA contains a packed data of length 15 and 5 decimal places. I should declare WVNUM variable exactly of length 15,5. If the length is more, then the decimal data error comes.

+ Reply to Thread

Similar Threads

  1. Problem with Date Type field and field Reference File
    By David Abramowitz in forum General
    Replies: 2
    Last Post: 07-27-2006, 10:32 AM
  2. Centering text within a field
    By Guest.Visitor in forum RPG
    Replies: 5
    Last Post: 03-18-2005, 08:03 AM
  3. Moving a date defined field to a numeric field using free format
    By buck.calabro@commsoft.net in forum General
    Replies: 2
    Last Post: 05-25-2004, 02:00 AM
  4. Moving numeric field to date data type field.
    By Guest.Visitor in forum Application Software
    Replies: 19
    Last Post: 08-20-2000, 04:21 AM
  5. centering text string
    By wjminc in forum Programming
    Replies: 3
    Last Post: 06-25-1998, 10:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts