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

Just starting out? Need help? Post your questions and find answers here.
hdt888
User
User
Posts: 51
Joined: Sun Jul 07, 2024 8:42 am

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

Post 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?
PB 5.x + 6.x + Win10. Feel the ...Pure... Power.
User avatar
STARGÅTE
Addict
Addict
Posts: 2253
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

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

Post 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))
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User avatar
mk-soft
Always Here
Always Here
Posts: 6285
Joined: Fri May 12, 2006 6:51 pm
Location: Germany

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

Post by mk-soft »

I thing is better to use an array ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Post Reply