The way I have found to address this is to create a compound variable (my term) where the item you have selected or obtained via process and stored as a variable is then listed as a variable by putting square bracket quotes around the first set of square bracket quotes. Example: [myvar] --> [[myvar]]
Initially I was concerned that the variable name would contaminate old data with new data that is initially obtained using the same variable name. As it turns out, you can prove that if you structure it correctly, each variable retains its integrity. You can prove this for yourself by creating a sample pub with a button and a ListBox (named Listbox1). Add the following as the button's action when clicked:
- Code: Select all
FileOpenBox "Select File" "Any File|*.*" "c:\" "[selectedfile]" ""
ExtractFileName "[selectedfile]" "[selectedfile]"
Random "1000" "[Rnumber]"
SetVar "[[selectedfile]]" "[Rnumber]"
ListBoxAddItem "ListBox1" "0" "[[selectedfile]]"
This pub selects a file, extracts the name of the file from the path and sets that filename as a variable name. You then assign a random number as the value of the variable and then store it in the listbox.
You will see in the debug screen that the variable IS CREATED AND NAMED by the action of selecting the file. As you select new files, new variables are created, each with their distinct name and assigned a distinct value. Of course if you select the same file twice you will overwrite the original value.
This is a helpful process to gather and display data about items but you don't know how many or what names you want to assign before the actual program is used.