Problem with fieldref of type Option

TbiTbi Member Posts: 33
Hi,
I am importing a textfile into a table and then there are some problem when I get a fieldref of type Option. (No, I cannot use dataport, its to be used in NAS).
I get an error saying : 'The expression Text cannot be Type-converted to an Option value' when I tries to set the value.
frFieldRef = Fieldref
sValue = Text[30]
iTmpInt = Integer



CASE frFieldRef.TYPE OF


'Option':
     BEGIN       
        IF STRPOS(UPPERCASE(frFieldRef.OPTIONCAPTION),UPPERCASE(sValue)) > 0 THEN BEGIN
             IF frFieldRef.OPTIONCAPTION[1] = ',' THEN BEGIN
                iTmpInt := 2;
             END
             ELSE BEGIN
               iTmpInt := 1;
               REPEAT 
                  iTmpInt += 1;
               UNTIL STRPOS(UPPERCASE(SELECTSTR(iTmpInt,frFieldRef.OPTIONCAPTION)),UPPERCASE(sValue)) = 0;
            END;

            frFieldRef.VALIDATE(SELECTSTR(iTmpInt,frFieldRef.OPTIONCAPTION));
       END;
   END;

What can I do to make this work?

Comments

  • SteveOSteveO Member Posts: 164
    Try using the EVALUATE command instead of VALIDATE.

    If you need to VALIDATE then call this after the EVALUATE.

    Haven't tried it myself but I think it might work
    This isn't a signature, I type this at the bottom of every message
  • TbiTbi Member Posts: 33
    I have also tried this, but it gives me an error saying: You cannot enter 'my value' in Option. The cursor is in front of the invalid character.
  • philippegirodphilippegirod Member Posts: 191
    I'm not sure I understood the question but.....
    if i remenber well, it seams that FieldRef var respect the language code of the database... so try to use 'my value in my language' instead of 'my value'....

    For instance i used to have a filter the next code :
    FieldReference.SETFILTER(STRSUBSTNO('%1','Text filter in my language'));
    

    and it worked......
    My candle burns by both ends, it will not last the night,
    But oh my foes and oh my friends, it gives a lovely light
  • NicevDKNicevDK Member Posts: 3
    In order to set the value of the option field to your input value I corrected the following line:
    frFieldRef.VALIDATE(SELECTSTR(iTmpInt,frFieldRef.OPTIONCAPTION));
    

    to
    EVALUATE(frFieldRef,FORMAT(iTmpInt));
    

    as mentioned above.. If you evaluate the frfieldref.optioncaption instead of validating it one get an type error. But inserting the integer variable the code returns the correct option ..
Sign In or Register to comment.