SETPOSITOIN -how to use it?

arcullarcull Member Posts: 191
Hi, does anyone know how to proprerly use setposition on recordref which points to a table with one single field in primary key. A simple example would help much, cause I can't figure it out
RecR.SETPOSITION('04');
does not work. RecR is of type RecordRef. Thanks for help.

Comments

  • BeliasBelias Member Posts: 2,998
    did you use "open" or "settable" functions on recordref before your instruction?
    Read help online for further informations. :wink:
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • krikikriki Member, Moderator Posts: 9,110
    Try something like this:
    rer.OPEN(DATABASE::"Your Table");
    
    fir := rer.FIELDID(nnn1); // where nn1 is the FIELDID of the first primary field
    fir.SETRANGE('04');
    
    // if you have other primary key fields, you can repeat the both fir lines for each primary keyfield
    
    IF rer.FINDFIRST THEN BEGIN
      // you found the record
    
    END;
    
    CLEAR(fir);
    CLEAR(rer);
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • arcullarcull Member Posts: 191
    Thanks for the work around kriki, but still I wonder how you can use it :) since setposition can be applied to regular record variables as well. OK, maybe I can use this thread for the further issue that I encounterd (if that's not OK, I'll open a new one) and that is: How can I test the type of field which fieldref points to? I tried
    IF FieldR2.TYPE = 'Code' THEN;
    
    and
    IF FieldR2.TYPE = FieldR2.TYPE::Code THEN;
    
    and
    IF FieldR2.TYPE = FieldR2.TYPE::'Code' THEN;
    
    and
    IF FieldR2.TYPE = FieldR2.TYPE::"Code" THEN;
    
    but it won't compile. Thanks for help again.
  • arcullarcull Member Posts: 191
    IF format(FieldR2.TYPE) = 'Code' THEN;
    
    is the winnig answer :)
  • krikikriki Member, Moderator Posts: 9,110
    arcull wrote:
    IF format(FieldR2.TYPE) = 'Code' THEN;
    
    is the winnig answer :)
    To make it even more sure:
    IF UPPERCASE(FORMAT(FieldR2.TYPE)) = 'CODE' THEN;
    
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • BeliasBelias Member Posts: 2,998
    you can use setposition with the result of "GETPOSITION" function.
    use a message to show what is generated...there is also a parameter...
    anyway, another questiond:
    I've this function, named FNTGetPar
    RRRecordRef.OPEN(INTLocTableNo);
    RRRecordRef.SETPOSITION(TXTLocPosition);
    FRFieldRef := RRRecordRef.FIELD(INTLocFieldNo);
    MESSAGE(FORMAT(FRFieldRef));
    

    and i call it with this:
    cu.FNTGetPar(cu.FNTGetTableNo(tbtest.TABLENAME),tbtest.FIELDNO(Name),tbtest.GETPOSITION(FALSE));
    
    all the parameters are set correctly in the function, but the message is blank.
    (maybe i'm doing a stupid error...)

    tbtest = record customer

    Please, no workarounds, because i need my parameters to be passed like the way i've done...when i'll finish the whole utility i'll post it
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
  • BeliasBelias Member Posts: 2,998
    Belias wrote:
    (maybe i'm doing a stupid error...)
    exactly #-o
    i forgot to do find('=') after the setposition

    here you can find my project ;)

    http://www.mibuso.com/forum/viewtopic.php?f=5&t=31763
    -Mirko-
    "Never memorize what you can easily find in a book".....Or Mibuso
    My Blog
Sign In or Register to comment.