Sign in to follow this  
Followers 0
RobMac

How to Store Variables in string then later evaluate

5 posts in this topic

I dont know the correct terminology for this so maybe not finding it in my searches.

I am trying to build a query based on settings I put in the first line of a tab delimited file. Then based on these settings and terms I want to run through the rest of the lines to actually run the queries.

So basically my question is how can I store a set of text and variable names in a string variable then later "use it" and have the variables inline be evaluated and replaced with their values. I know how to do everything besides creating a string with variables that will later evaluate to replace variables with values.

Example:

If my top row from my input file was:

( 1 and ( 2 or 3 or 4 ) .

I would want to create a variables that says: "( $instring[1] and ( $instring[2] or $instring[3] or $instring[4] )"

(Obviously if this line was different I would want to create a different arangement of variables for the query string).

Then when these values are read in from later lines:

Fruit apple pear peach

Vegetable carrot tomato squash

Should turn into:

( Fruit and ( apple or pear or peach )

( Vegetable and ( carrot or tomato or squash )

Thanks as always for any help.

-Rob

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about...

$sMyString = "( " & $instring[1] & " and ( " & $instring[2] & " or " & $instring[3] & " or " & $instring[4]) "

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites

Thanks I guess I should have trusted my choice of "evaluate" as the term describing what I wanted to do and searched on that.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks I guess I should have trusted my choice of "evaluate" as the term describing what I wanted to do and searched on that.

You are welcome in AutoIt's world :-)

Answers for 99% of all questions are in AutoIt helpfile

trust me I know what I'm talking about because I read it :-))

Edited by Zedna

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0