Wave59 Bulletin Board

 
 
  
 Search
  
 Posted Today
  
 Most Active
  
 Help   
 » Home »   » Wave59 Forums »   » Wave59 Scripts »   » string to number / input array


 View Previous Topic
View Next Topic 

   string to number / input array
P:  7/11/2008 2:45:32 AM
lolero

Member

Total Posts: 117
Last Post: 8/20/2010
Member Since: 2/12/2008

hi all,
i run into a problem writing a script that i can get around in one of two ways: allowing the user to input an array, or using a string as a number.
is it possible to input an array to a script? or to convert the numbers in a string to numbers usable in the script calculations?
any thoughts are greatly appreciated.
best regards,

 


lolero

Revisions : 0   |    Posted:  7/11/2008 2:45:32 AM   |   IP:  Recorded    |    Report this post


 There are 4 replies to this message.  There are 4 replies on this page.

P: 7/11/2008 4:55:53 AM
rhythmstic

Member

Total Posts: 985
Last Post: 8/20/2010
Member Since: 1/4/2005

Hi Iolero
You can input an array from a text file using file_read (see scripting help: file_).
You can force strings as numbers using to_Double(X) (see scripting help: data types).

stic

Revisions : 0   |    Posted:  7/11/2008 4:55:53 AM    |    IP:  Recorded    |    Report this post
P: 7/11/2008 6:56:51 AM
lolero

Member

Total Posts: 117
Last Post: 8/20/2010
Member Since: 2/12/2008

stic,
that helps a lot.
thanks!

lolero

Revisions : 0   |    Posted:  7/11/2008 6:56:51 AM    |    IP:  Recorded    |    Report this post
P: 7/11/2008 8:31:16 AM
kjociii

Member

Total Posts: 163
Last Post: 7/6/2010
Member Since: 6/16/2005

Hi Lolero,
If you want to have an array as an input just have the user enter the data as a string and delimit the variables with something like a comma.  You can then use the split function in QScript to get the variables into the array.
-Ken

Revisions : 0   |    Posted:  7/11/2008 8:31:16 AM    |    IP:  Recorded    |    Report this post
P: 2/6/2010 9:10:42 PM
rhythmstic

Member

Total Posts: 985
Last Post: 8/20/2010
Member Since: 1/4/2005

.. OR to hard wire a list within the script you can probably ...

  #~~~~~ define vars
  Doctor_Fu_Manchu, Miss_Scarlett, Professor_Moriarty = 0;

  #~~~~~ insert list of values into the string
  Professor_Moriarty = Join(",",11,22,33,44,55,66,77,88,99,101);

  #~~~~~ set up array
  define ARRAY Inspector_Javert[];  Inspector_Javert[0]=0;

  #~~~~~ populate array Inspector_Javert
  Doctor_Fu_Manchu = split(Inspector_Javert,Professor_Moriarty,",");

  #~~~~~ force each value from a string value to a number value
  for (ctr = 0 to length(Inspector_Javert) -1 by 1) {#~ctr
      Miss_Scarlett = to_double(Inspector_Javert[ctr]);
      print Miss_Scarlett; #~~~ or do whatever you want with her 
        }#~ctr

stic

Revisions : 0   |    Posted:  2/6/2010 9:10:42 PM    |    IP:  Recorded    |    Report this post

 Previous Page
Next Page 

Jump to:



Contact Us  |  Back Home  |  Privacy Statement

Ideal BB Version: 0.1.5.4bMessage forum software powered by  the Ideal BB