Assigning Text values to an Option Variable

cloudnine
cloudnine Member Posts: 25
How do you guys do assigning of text values to an Option variable...Thanks

Comments

  • alwaysguna
    alwaysguna Member Posts: 45
    If You want to add text then you need to update the option string of the variable
    Guna
  • cloudnine
    cloudnine Member Posts: 25
    What i want to do is during runtime...I want to assign a set of texts that will serve as option one i choose another option...Thanks
  • alwaysguna
    alwaysguna Member Posts: 45
    If you want to add dynamically then i think its not possible
    Guna
  • Thomas_Hviid_Thorn
    Thomas_Hviid_Thorn Member Posts: 92
    Hej cloudnine,

    you have to make a repeat to find the appropriate option-value:
      idx : integer;
      found : Boolean;
      OptText : Text(30);
      Options : "Zero,One,Two,Three,Four";
    
      OptText := 'Three';
      idx := 0;
      REPEAT
        Options := idx;
        idx += 1;
        found := FORMAT(Options,0,'<text>') = OptText;
      UNTIL (found)
             OR (DELCHR(FORMAT(Options,0,'<text>'),'=','0123456789') = '');
    

    The
    DELCHR(FORMAT(Options,0,'<text>'),'=','0123456789') = ''
    is used to stop the loop, if there is no match.
    If Options = 5 will make FORMAT(Options,0,'<text>') = '5'

    I hope it'll be helpfull for you.
    With Kind Regards
    Thoms Hviid Thorn
  • matteo_montanari
    matteo_montanari Member Posts: 189
    cloudnine wrote:
    What i want to do is during runtime...I want to assign a set of texts that will serve as option one i choose another option...Thanks

    Do you want to update a option field from a user text?

    something like:

    EVALUATE(Option, Text);

    ?

    Matteo
    Reno Sistemi Navision Developer
  • Thomas_Hviid_Thorn
    Thomas_Hviid_Thorn Member Posts: 92
    ... another comment:

    If you're using 3.7 or 4.0 and your option-variable is a table field, you may use RecordRef/FieldRef and the functionality here to make the code nicer.

    I have no code example on that, though. Here you're on you own :)
    With Kind Regards
    Thoms Hviid Thorn
  • cloudnine
    cloudnine Member Posts: 25
    Eto,

    That's most likely i want to do...update an option variable based on the user text...for example i entered "test" in text variable...the value of option variable should be "test1, test2, test3"...then if i entered "testing" in text variable...the value of option variable should be "testing1, testing2, testing3"...would that be possible...How is it implemented in C/SIDE...Thanks...
  • kine
    kine Member Posts: 12,562
    You can use some table into which you add the strings and open it in Lookup form for the user. No way through option type...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.