Page 1 of 1
Create tables
Posted: Wed Oct 02, 2019 11:10 am
by sashapont
I want to create many table in runtime I don't know how mucky it will be at the program start. How I can do it in for next like?
Code: Select all
For t = 1 to c
MenuItiem..[t]..$={}
Next
Re: Create tables
Posted: Wed Oct 02, 2019 2:01 pm
by Clyde
To create the table at runtime you would do something like:
Code: Select all
For t = 1 to c
MenuItiem[t] = yourDynamicValue
Next
Re: Create tables
Posted: Wed Oct 02, 2019 7:37 pm
by sashapont
Is not work!
Table menuitiem{} not found!
Re: Create tables
Posted: Wed Oct 02, 2019 9:05 pm
by SamuraiCrow
Let's try again. You are trying to generate names dynamically? If so it needs to be inside an outer table.
Code: Select all
MenuItem={}
For t=0 to c
MenuItem[t]={}
Next
Re: Create tables
Posted: Wed Oct 02, 2019 9:12 pm
by sashapont
SamuraiCrow wrote: ↑Wed Oct 02, 2019 9:05 pm
Let's try again. You are trying to generate names dynamically? If so it needs to be inside an outer table.
Code: Select all
MenuItem={}
For t=0 to c
MenuItem[t]={}
Next
No I want many tables for example I want:
MenuItiem1$={1,2,3..}
MenuItiem2$={1,2,3...}
MenuItiem3$={1,2,3...}
...
MenuItiem100$={1,2,3...}
Re: Create tables
Posted: Wed Oct 02, 2019 9:19 pm
by SamuraiCrow
You still need to put those 100 tables in an outer one. You can use a string concatination to generate a key value. Local and Global variables cannot use dynamic names.
Code: Select all
Global tbl={}
For t=0 to c
tbl["MenuItem"..StrStr(t).."$"]={}
Next
Re: Create tables
Posted: Wed Oct 02, 2019 9:32 pm
by sashapont
SamuraiCrow wrote: ↑Wed Oct 02, 2019 9:19 pm
You still need to put those 100 tables in an outer one. You can use a string concatination to generate a key value. Local and Global variables cannot use dynamic names.
Code: Select all
Global tbl={}
For t=0 to c
tbl["MenuItem"..StrStr(t).."$"]={}
Next
I don't understand clearly....
I use this code and than
SystemRequest("tbl", ListItems(tbl), "OK",#REQICON_WARNING)
I have 0. Why not 100?
Re: Create tables
Posted: Wed Oct 02, 2019 10:58 pm
by Bugala
Actually it is possible to affect Global variables names in Hollywood since all variables are stored in table "_G":
However, I do recommend sticking on multiple dimension table rather.
Re: Create tables
Posted: Thu Oct 03, 2019 8:10 am
by SamuraiCrow
sashapont wrote: ↑Wed Oct 02, 2019 9:32 pm
I use this code and than
SystemRequest("tbl", ListItems(tbl), "OK",#REQICON_WARNING)
I have 0. Why not 100?
Use
TableItems() instead of
ListItems() because it isn't an array.