Sign in to follow this  
Followers 0
Wishiwasmarter

How to create menus from csv files?

2 posts in this topic

Hi there,

I'm new to AutoIT after using macro express for years and have some questions how to do things that I found rather easy with macro express pro. I've watched most of the youtube videos and have read the tutorial files, but I'm still left wondering how to do the following:

1- Is there a simple way to read a csv file with 2 records per line into 2 separate variables so I can use them in operations?

ex: chocolate syrup, 2.00 into $sTopping and $nPrice.

2- Is there an elegant way to read a csv file of about 50 lines, with 2 records per line, into a menu of choices (probably using checkboxes), and then use those choices in a later function? With MEP, I read each line into 2 variables (say, each line contains an ice cream topping and the price), use them to append a larger variable which is used in the menu (it becomes a list of all ice cream toppings and prices), then run an operation that compares everything selected in the menu against the original file, (hence, if the ice cream topping in the file is also a menu choice, that topping is added to a running total).

3- If that isn't already too much, I'd like to create a menu that has 4 different tabs, each like question number 2, listing 20-50 choices for each tab. (say, cone, sundae, etc)

Lastly, is there a book somewhere that has more advanced concepts than the basic tutorials?

Any help with this or where to look for answers would be appreciated.

Mike

Share this post


Link to post
Share on other sites



1- Is there a simple way to read a csv file with 2 records per line into 2 separate variables so I can use them in operations?

ex: chocolate syrup, 2.00 into $sTopping and $nPrice.

Yes, there is. You can open the .csv file in Excel and then read it into an array using _ExcelReadSheetToArray() from the Excel UDF. Having this Array you can either directly access the single sets of data or declare variables with the array values.

One Example:

$aExcel = _ExcelBookOpen("O:\Whatever Folder\Whatever file.csv)
$array = _ExcelReadSheetToArray($aExcel,1,1,0,0,True)
_ExcelBookClose($aExcel,  0,  0)

$variableX = $array[3][1]  ; declares a variable with a value from the array
msgbox(0,"",$array [3][1]) ; displays the value from the Row 3, Column 1
_ArrayDisplay($array,"")   ; shows what you have read to the array

For your second question, Getting the data would be the same procedure as listed for question 1. For GUI, you'll I am the wrong person to ask unfortunately...

Good Luck

Will

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