Jump to content

Turn "String" into "Variable"


Go to solution Solved by iamtheky,

Recommended Posts

Hi there! I am new to to programming (this is my first post on this forum).  By searching for a program that can upload files on websites, I found AutoIt. I'm the type of person who searches and tries just about everything before asking questions, so, the fact that I'm writing this means I couldn't find the answer and it's worth asking so that someone like me can find the answer one day.

My question is: can I turn a string of text into a variable? This might be a no-brainer for you professionals out there, but to me it's a puzzle.

Here's what I'm trying to do:

Global $counter = 0
Global $AMOUNT = 2
Global $A1 = ('"CAT.JPG" ') & ('"DOG.JPG" ')
Global $A2 = ('"TURTLE.JPG" ') & ('"COW.JPG" ')

Do
Local $A = "$A" & $counter+1 ; <--- THIS CREATES A VARIABLE CALLED "$A" AND COMBINES "$A" + "LOOP NUMBER"
Send($A) ; <--- THIS SENDS "$A1" LITERALLY (AS TEXT) BUT I WANT IT TO SEND "$A1" AS A VARIABLE WHICH IS: CAT.JPG AND DOG.JPG
Send ("{ENTER}") ; <--- CLICKS ENTER TO UPLOAD IMAGES
$counter = $counter + 1
Until $counter = $AMOUNT ; <--- THIS CAUSES IT TO LOOP, ONLY THIS TIME, IT SHOULD BE $A2 (TURLE.JPG AND COW.JPG)

Basically, I'm trying to get $A to equal $A1 and $A2 (depending on the loop count).
Right now, I'm getting $A to send $A1 as text instead of sending the variable $A1.

Please help!

Thank you! :)

Link to comment
Share on other sites

Global $counter = 0
Global $AMOUNT = 2
Global $A1 = ('"CAT.JPG" ') & ('"DOG.JPG" ')
Global $A2 = ('"TURTLE.JPG" ') & ('"COW.JPG" ')


Do
Local $A = "A" & $counter+1 ; <--- THIS CREATES A VARIABLE CALLED "$A" AND COMBINES "$A" + "LOOP NUMBER"
send(eval(eval("A"))) ; <--- THIS SENDS "$A1" LITERALLY (AS TEXT) BUT I WANT IT TO SEND "$A1" AS A VARIABLE WHICH IS: CAT.JPG AND DOG.JPG
Send ("{ENTER}"); <--- CLICKS ENTER TO UPLOAD IMAGES
$counter = $counter + 1
Until $counter = $AMOUNT

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
Share on other sites

  • Solution

when i put my cursor below that text in scite and press F5, it writes the content of A1 and A2. I also changed the line where you set the variable, there is no $ sign in the quotes. use msgbox or consolewrite for debug.

 

Global $counter = 0
Global $AMOUNT = 2
Global $A1 = ('"CAT.JPG" ') & ('"DOG.JPG" ')
Global $A2 = ('"TURTLE.JPG" ') & ('"COW.JPG" ')


Do
Local $A = "A" & $counter+1 ; <--- THIS CREATES A VARIABLE CALLED "$A" AND COMBINES "$A" + "LOOP NUMBER"
;~ send(eval(eval("A"))) ; <--- THIS SENDS "$A1" LITERALLY (AS TEXT) BUT I WANT IT TO SEND "$A1" AS A VARIABLE WHICH IS: CAT.JPG AND DOG.JPG
;~ Send ("{ENTER}"); <--- CLICKS ENTER TO UPLOAD IMAGES
msgbox(0, '' , eval(eval("A")))
$counter = $counter + 1
Until $counter = $AMOUNT
Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...