Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Is it possible to convert a string to a label?

Author
Message
The InTIMidator
19
Years of Service
User Offline
Joined: 22nd Jun 2005
Location: Somerset, UK
Posted: 15th Jun 2006 16:13
Hi, I'm a novice programmer at dark basic and I was wondering if you could convert a string to a label for example:

I know this does not work, but it would really help if there is.
So, is there a way to overcome this problem or are you going to have to type:

Thankyou
The InTIMidator

"Press any key ... where's the any key"
AMD Athlon 64 3400, 1 Gb RAM, Radeon 9800 pro, 80GB HDD
MadrMan
18
Years of Service
User Offline
Joined: 17th Dec 2005
Location: 0x5AB63C
Posted: 15th Jun 2006 19:16
The last one will do, but you could put all your subs in big if's. dont know how your code works, but you could try to instead of putting a 'sub:' , a 'if input$="sub"', you wouldnt have to make all the input code.

Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 15th Jun 2006 20:36
I think what you are looking for is SELECT

In this example, you end up with more lines, but you can expand on it as much as you want.

or, using Arrays

There are a variety of ways you can do what you want. If you told us more about what you are doing, we can help more.

P.S. It is good programming practice to utterly avoid 'goto's and 'label's - function based programming is the better way.
E.g.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 15th Jun 2006 22:20
to answer the question, no, the label name in code cannot be a variable, you would need condition tests like the advice above

The InTIMidator
19
Years of Service
User Offline
Joined: 22nd Jun 2005
Location: Somerset, UK
Posted: 16th Jun 2006 13:51
Thanks alot guys,
That SELECT function is just what I need or else I would be having to write alot of labels.
Quote: "
...but you could put all your subs in big if's. dont know how your code works, but you could try to instead of putting a 'sub:' , a 'if input$="sub"', you wouldnt have to make all the input code.
"

Not too sure what you are saying here, could you be a little more specific Madrman...
Quote: "
P.S. It is good programming practice to utterly avoid 'goto's and 'label's - function based programming is the better way.
"

Yes that is quite right and I will try to do more functions.
Another thing, my subs and labels have to be accessed from different parts of the game from different angles if you get me,
so in some cases i may need to have labels, won't I?... but will use that SELECT command, just the ticket !!
Thanks alot guys

"Press any key ... where's the any key"
AMD Athlon 64 3400, 1 Gb RAM, Radeon 9800 pro, 80GB HDD
The InTIMidator
19
Years of Service
User Offline
Joined: 22nd Jun 2005
Location: Somerset, UK
Posted: 16th Jun 2006 16:04
Quote: "If you told us more about what you are doing, we can help more."

Okay, I'm trying to make a text-based adventure game for the compo and im just trying to find an easier way to do the gotos in a better way...

I know this is not right but if ONLY!!!!
Would I have to do a function? Or would it just be easier to just do it in gotos and labels?
Thanks
The InTIMidator

"Press any key ... where's the any key"
AMD Athlon 64 3400, 1 Gb RAM, Radeon 9800 pro, 80GB HDD
Three Score
20
Years of Service
User Offline
Joined: 18th Jun 2004
Location: behind you
Posted: 16th Jun 2006 20:47
@intimeidator
are you trying to make an array of labels *gasp*
what exactly would be the point of that
if this was C then you could possibly do that but why!?

on the note of goto's they are horrible coding practice but they do have their uses the problem with them is you have to use them in global code(not in a gosub or function) or it will cause a pileup on the stack; it holds the returning information for the function/gosub and if its not taken off and used then theres a chance for it to just keep on going making a fatal memory leak

JouleOS and friends
great thanks to http://galekus.com for FREE HOSTING!

Login to post a reply

Server time is: 2024-11-26 17:39:16
Your offset time is: 2024-11-26 17:39:16