Advertisement
Dorex

Parse Text and Integer

Feb 10th, 2016
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. string Text;
  2. string Value;
  3. //
  4. // parse a string and get the text and integer from it.
  5. // only works for one word and one integer.
  6. // yes this works 10, 10yes, 10Yes 10.99yes it does   work
  7. // yes10no1 doesn't work
  8. // cast Value to integer or float as needed.
  9. //
  10. parseInput(string input)
  11. {
  12.     integer index;
  13.  
  14.     while (index<llStringLength(input)){
  15.         string character= llGetSubString(input,index,index);
  16.         if((integer)character || llSubStringIndex("0.",character)>-1){
  17.             Value+= character;
  18.         } else{
  19.             Text+=character;
  20.         }
  21.         index++;
  22.     }
  23. }
  24. default
  25. {
  26.     touch_start(integer total_number)
  27.     {
  28.        
  29.         string input = "yes this works10.99";
  30.         Text="";
  31.         Value="";
  32.         parseInput(input);
  33.         llOwnerSay("text " + Text + " - value " + Value);
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement