how to do Looping in looping?

bangswitbangswit Member Posts: 265
hi all
i want to do looping in looping
how to do that?
on pre data item
Item - OnPreDataItem()
Location.FIND('-');
i:= 1;
REPEAT
LocName := Location.Code;
i:= i +1;
UNTIL
(Location.NEXT=0) OR (i>Location.COUNT);

in section (report)
i already done like this
Location 1 Location 2 Location 3 Location 4 Location 5
Location.FINDFIRST;
n :=0 ;
REPEAT
n := n+1;
XLRow(FORMAT(LocName[n]));
ExcelBuf.NewRow;
UNTIL Location.NEXT= 0;

but all i want is to be like this
Location 1 Location 2 Location 3
Location 4 Location 5
so i create code like this

Location.FINDFIRST;
n :=0 ;
REPEAT
n := n+1;
FOR x:=1 TO 3
DO
XLRow(FORMAT(LocName[n]));
NEXT;
ExcelBuf.NewRow;
UNTIL Location.NEXT= 0;
--> Failed :(

Comments

  • ProcatProcat Member Posts: 31
    Location.FINDFIRST;
    n := 0;
    REPEAT
    n += 1;
    FOR x:= n TO n+3 DO BEGIN
    XLRow(FORMAT(LocName[x]));
    END;
    ExcelBuf.NewRow;
    UNTIL Location.NEXT= 0;

    You might wanna add something like:
    IF Arraylen(LocName) > X THEN
    XLRow(FORMAT(LocName[x]));
  • bangswitbangswit Member Posts: 265
    Nope
    it's still wrong
    your code make my report like this
    Location 1 Location 2 Location 3 Location 4
    Location 2 Location 3 Location 4 Location 5
    Location 3 Location 4 Location 5
    Location 4 Location 5
    Location 5
  • BeliasBelias Member Posts: 2,998
    what do you want to achieve, in simple words?
    write only in columns A,B,C and then change row?
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bangswitbangswit Member Posts: 265
    Belias wrote:
    what do you want to achieve, in simple words?
    write only in columns A,B,C and then change row?
    I'm sorry?
    i don't know what you mean...

    i want to create reports Item By Location
    because the location is too many to sideways
    so i want to limit it only 3 location sideways
    the remains is show below it...
  • BeliasBelias Member Posts: 2,998
    you're writing in an excel file, isn't it?
    so, if you have 6 location, you want to write the first three in the first three columns in excel (A,B,C) and then write the rest of the location in the second row of excel
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • bangswitbangswit Member Posts: 265
    Belias wrote:
    you're writing in an excel file, isn't it?
    so, if you have 6 location, you want to write the first three in the first three columns in excel (A,B,C) and then write the rest of the location in the second row of excel
    That's right !
    i want to do like that
  • BeliasBelias Member Posts: 2,998
    (i don't know the structure and purpose of the report, but my first guess is to do)

    onprereport
    rownumber := 1;
    colnumber := 0;
    

    location - onaftergetrecord
    if colnumber > 3 then begin
      rownumber += 1;
      colnumber := 1;
    end else
      colNumber +=1;
    //write in excel cell with position rownumber,colnumber  <-- i use a custom function for this. when i've time, i'll post it...anyway, it is a popular function that you can find on mibuso
    
    for the function try to search "FALSE,FALSE,FALSE" in mibuso, you'll probably find it..
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,110
    BTW:
    NEVER USE
    IF FINDFIRST THEN
      REPEAT
    
      UNTIL NEXT = 0;
    

    but use:
    IF FINDSET THEN // or FIND('-') or FIND('+')
      REPEAT
    
      UNTIL NEXT = 0;
    
    see also this for more info : http://www.mibuso.com/howtoinfo.asp?FileID=22
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • bangswitbangswit Member Posts: 265
    Belias wrote:
    (i don't know the structure and purpose of the report, but my first guess is to do)

    onprereport
    rownumber := 1;
    colnumber := 0;
    

    location - onaftergetrecord
    if colnumber > 3 then begin
      rownumber += 1;
      colnumber := 1;
    end else
      colNumber +=1;
    //write in excel cell with position rownumber,colnumber  <-- i use a custom function for this. when i've time, i'll post it...anyway, it is a popular function that you can find on mibuso
    
    for the function try to search "FALSE,FALSE,FALSE" in mibuso, you'll probably find it..

    eiy i already got the answer
    just like this
    Column:=4;
    Location.FINDFIRST;

    n :=0 ;
    REPEAT
    x := n MOD Column;
    n := n+1;
    IF x = 0 THEN
    BEGIN
    ExcelBuf.NewRow;
    FOR EmptySpace := 1 TO 7 DO
    BEGIN
    XLRow('');
    END;
    END;
    XLRow(FORMAT(LocName[n]));
    UNTIL Location.NEXT= 0;

    thanks for any help \:D/
  • bangswitbangswit Member Posts: 265
    kriki wrote:
    BTW:
    NEVER USE
    IF FINDFIRST THEN
      REPEAT
    
      UNTIL NEXT = 0;
    

    but use:
    IF FINDSET THEN // or FIND('-') or FIND('+')
      REPEAT
    
      UNTIL NEXT = 0;
    
    see also this for more info : http://www.mibuso.com/howtoinfo.asp?FileID=22

    ok
    thanks a lot kriki
    for the info
  • vaprogvaprog Member Posts: 1,139
    bangswit,

    please use Code tags for posting code, not Quote tags. It makes the code much easier to read because indentation is preserved.
  • bangswitbangswit Member Posts: 265
    owww ok2
    sorry about that
    test
    
Sign In or Register to comment.