Discuss any general programming issues here
sashapont
Posts: 152 Joined: Thu Aug 03, 2017 2:49 pm
Post
by sashapont » Wed Oct 02, 2019 11:10 am
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
Clyde
Posts: 349 Joined: Sun Feb 14, 2010 12:38 pm
Location: Dresden / Germany
Post
by Clyde » Wed Oct 02, 2019 2:01 pm
To create the table at runtime you would do something like:
Code: Select all
For t = 1 to c
MenuItiem[t] = yourDynamicValue
Next
Currently using: Hollywood 9 with Windows IDE and Hollywood 9 with Visual Studio Code and
hw4vsc
sashapont
Posts: 152 Joined: Thu Aug 03, 2017 2:49 pm
Post
by sashapont » Wed Oct 02, 2019 7:37 pm
Is not work!
Table menuitiem{} not found!
SamuraiCrow
Posts: 475 Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA
Post
by SamuraiCrow » 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
I'm on registered MorphOS using FlowStudio.
sashapont
Posts: 152 Joined: Thu Aug 03, 2017 2:49 pm
Post
by sashapont » Wed Oct 02, 2019 9:12 pm
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...}
SamuraiCrow
Posts: 475 Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA
Post
by SamuraiCrow » 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'm on registered MorphOS using FlowStudio.
sashapont
Posts: 152 Joined: Thu Aug 03, 2017 2:49 pm
Post
by sashapont » Wed Oct 02, 2019 9:32 pm
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?
Bugala
Posts: 1181 Joined: Sun Feb 14, 2010 7:11 pm
Post
by Bugala » Wed Oct 02, 2019 10:58 pm
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.
SamuraiCrow
Posts: 475 Joined: Fri May 15, 2015 5:15 pm
Location: Waterville, Minnesota USA
Post
by SamuraiCrow » Thu Oct 03, 2019 8:10 am
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.
I'm on registered MorphOS using FlowStudio.