arayante Posted April 1, 2008 Share Posted April 1, 2008 My mind is pretty numb today so maybe I'm just not thinking of a different solution to this problem: My script is reading cells in a spreadsheet and assigning the data to variables. I now want to enter this data into a form (using the variables), but since I have a large number of variables I'd rather not detail each send function. I'd rather use For...To..Next to put all similar sets of data into loops. So the below is an example of what I've got so far. Data from the spreadsheet: A1 = FirstName assigned to $A1 A2 = LastName assigned to $A2 A3 = Age assigned to $A3 The long, hard way to enter this data looks like this now: send(""$A1&"{TAB}"&$A2&"{TAB}"&$A3&"") I haven't been able to concatenate variables and I haven't found any examples of this. Could I make something that will Step a value in my variable so it runs A1, then A2, etc? for $n = 1 to 3 send (" "&$A"&$n&"&"{TAB} next The effect in my example would be that FirstName is entered into the first field in the form, then LastName in the next field, and finally Age. Link to comment Share on other sites More sharing options...
junkew Posted April 1, 2008 Share Posted April 1, 2008 Dim $a[3] for $n=0 to 2 send (" "& $A[$n] & "&"{TAB}) next FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
spudw2k Posted April 1, 2008 Share Posted April 1, 2008 I'd use junkew's approach, but you can also use the Execute() function if you'd prefer not to use an array like junkew's example. It is easier. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
covaks Posted April 1, 2008 Share Posted April 1, 2008 #include <Misc.au3> Dim $a[3] = ["Bob","Jones","25"] For $x = 0 to 2 Send($a[$x] & _Iif($x < 2,"{TAB}","")) Next Link to comment Share on other sites More sharing options...
spudw2k Posted April 1, 2008 Share Posted April 1, 2008 #include <Misc.au3> Dim $a[3] = ["Bob","Jones","25"] For $x = 0 to 2 Send($a[$x] & _Iif($x < 2,"{TAB}","")) Next Nice Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF Link to comment Share on other sites More sharing options...
MHz Posted April 2, 2008 Share Posted April 2, 2008 (edited) I would consider a 2 dimension Array for a spreadsheet as it would suit. Have a look at this Wiki page here for a good explaination of Array usage. You may also search the Example Scripts forum for a ExelCom based UDF if you are using M$ Exel. Edited April 2, 2008 by MHz Link to comment Share on other sites More sharing options...
arayante Posted April 4, 2008 Author Share Posted April 4, 2008 OK this has been a lot of help so far, but I'm not there yet. I've spent a lot of time studying the usage and relationship of variables and arrays and I have some more questions. What covaks has in post 4 is great for me. What I'm thinking is: 1) My script reads the spreadsheet. Let's assume it's 4x3 Columns x Rows, labeled A1...3, B1...3, etc 2) The script assigns each cell A1 through D3 to a variable $A1 through $D3. 3) Now I want to use these variables in an array ($arr[4][3]), which I understand would be defined as dim $arr[4][3] = [[$A1,$A2,$A3],[$B1,$B2,$B3],[$C1,$C2,$C3],[$D1,$D2,$D3]] (is that right?) Assuming that's right, is there an easy way to mass-define an array full of variables like this? Suppose I have $arr[200][5]. I don't want to define 1000 variables by hand! Can I use a For statement to define a huge array full of variables? Link to comment Share on other sites More sharing options...
everseeker Posted April 4, 2008 Share Posted April 4, 2008 (edited) OK this has been a lot of help so far, but I'm not there yet. I've spent a lot of time studying the usage and relationship of variables and arrays and I have some more questions. What covaks has in post 4 is great for me. What I'm thinking is: 1) My script reads the spreadsheet. Let's assume it's 4x3 Columns x Rows, labeled A1...3, B1...3, etc 2) The script assigns each cell A1 through D3 to a variable $A1 through $D3. 3) Now I want to use these variables in an array ($arr[4][3]), which I understand would be defined as dim $arr[4][3] = [[$A1,$A2,$A3],[$B1,$B2,$B3],[$C1,$C2,$C3],[$D1,$D2,$D3]] (is that right?) Assuming that's right, is there an easy way to mass-define an array full of variables like this? Suppose I have $arr[200][5]. I don't want to define 1000 variables by hand! Can I use a For statement to define a huge array full of variables? What you need is http://www.autoitscript.com/forum/index.ph...hl=ExcelCOM_UDF Specificly, the function _ExcelReadArray() which is used to load parts of a spreadsheet into an array Edited April 4, 2008 by everseeker Everseeker Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now