Page 1 of 1

Randomly select a declared Constant (string/number type) ?

Posted: Sun Oct 12, 2025 9:46 am
by hdt888
I have declared the constant:

Code: Select all

#Book_on_shelf1 = "Hello world - Basic program"
#Book_on_shelf2 = "How to learn PureBasic ?"
#Book_on_shelf3 = "PureBasic on Internet !!!"

#Bookshelf_location1 = 1
#Bookshelf_location2 = 2
#Bookshelf_location3 = 3
How can I randomly select a declared Constant (string/number type) from these 3 constants?

Re: Randomly select a declared Constant (string/number type) ?

Posted: Sun Oct 12, 2025 9:58 am
by STARGĂ…TE
With Runtime:

Code: Select all

#Book_on_shelf1 = "Hello world - Basic program"
#Book_on_shelf2 = "How to learn PureBasic ?"
#Book_on_shelf3 = "PureBasic on Internet !!!"

Runtime #Book_on_shelf1, #Book_on_shelf2, #Book_on_shelf3

Debug GetRuntimeString("#Book_on_shelf"+Random(3,1))

Re: Randomly select a declared Constant (string/number type) ?

Posted: Sun Oct 12, 2025 10:07 am
by mk-soft
I thing is better to use an array ...