Low Level Copy

Big_DBig_D Member Posts: 207
Hi Mibuso.com World

Hope all well :D !

Thought this was gonna be a walk in the park, copying the Records and Fields from one Company Table to another but no so....


lRecref.OPEN (312, FALSE, 'Test Company #1');
lRecref2.OPEN (312, FALSE, 'Test Company #2');
Loopy := 0;
IF lRecref.FIND ('-') THEN
REPEAT
lRecref2.INIT;
WHILE (Loopy < lRecref.FIELDCOUNT) DO
BEGIN
Loopy := Loopy + 1;
FieldRef := lRecref.FIELDINDEX(Loopy);
IF FieldRef.ACTIVE THEN
BEGIN
FieldRef2 := lRecref.FIELD(FieldRef.NUMBER);
FieldRef2.VALUE := FieldRef.VALUE;
END;
END;
lRecref2.INSERT;
Steps := lRecref.NEXT;
UNTIL Steps = 0;
lRecref.CLOSE;

The above code copies some of the fields to the Table 312 in the next Company but not all of them?

Thanks for your help :D!
Big D signing off!

Comments

  • geordiegeordie Member Posts: 655
    Can you try using EVALUATE instead of direct assignment?
    EVALUATE(FieldRef2.VALUE,FieldRef.VALUE);
    

    Furthermore, if you have any FlowFields you need to use the CALCFIELDS before assigning the value to the other FieldRef.
  • Big_DBig_D Member Posts: 207
    Hi geordie

    Thanks for your help but the evaluate command doesn't compile. Thanks for the Calcfield tips but thankfully none on our Table 312 :D!

    With thanks
    Big D signing off!
  • vaprogvaprog Member Posts: 1,141
    Try using
    FieldRef2 := lRecref2.FIELD(FieldRef.NUMBER);
    //                  ^ note the added character 2 here
    
    A simple
    FieldRef2.VALUE := FieldRef.VALUE;
    
    should work for any field type except TableFilter for which I use
    EVALUATE(FieldRef2, FORMAT(FieldRef.VALUE))
    
    Of course you need CALCFIELDS for Blob fields and there is no use in copying Flowfields and FlowFilterFields in a scenario such as yours.

    And, please, use [code] tags when posting code here. It is so much easier to read when properly indented.
  • Big_DBig_D Member Posts: 207
    Well done Sir your cracked it =D>!
    Big D signing off!
Sign In or Register to comment.