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.

DarkBASIC Professional Discussion / Loading File Issue

Author
Message
Divided
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 15th Nov 2014 15:34
Hey!

So, I want to load some data saved from a file, from this data I want the
3rd item in the array to be the label that the "Goto" function goes to.

Assume that a "c:" label has already been created.



I'll assume that the issue lies within the fact it's trying to go to a
string.

Please give me a possible solution to this conundrum.

Cheers!



DividedV -- YouTube Channel
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 15th Nov 2014 16:09
You can't create labels from variables. You'd have to do something like:



I like offending people. People who get offended should be offended. -- Linus Torvalds
gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 16th Nov 2014 17:24 Edited at: 16th Nov 2014 17:33
hmmm. First lesson:
Do not use goto use a function!

below is an example of how to make a function and pass a single parameter.




--------
DBP Archive
Divided
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 17th Nov 2014 01:29
Thank you for the reply!

Quick question, what is wrong with the "goto" function?

DividedV -- YouTube Channel
gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 17th Nov 2014 04:39
Goto causes the program to jump to a new location in the program however it does not return. In fact it forgets where it came from as well as all data that was there.

Functions on the other hand both return and have the advantage of passing and returning data. This of course is totally optional as in you do not have to pass or return a parameter (see code)



--------
DBP Archive
Divided
FPSC Reloaded TGC Backer
12
Years of Service
User Offline
Joined: 31st Oct 2013
Location:
Posted: 17th Nov 2014 14:28
Alright cheers!

I had no idea.
This will be very helpful later on but for my purposes I'll stick to the much hated "goto" function for noob sake.



DividedV -- YouTube Channel
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 17th Nov 2014 14:42 Edited at: 17th Nov 2014 14:54
Quote: "In fact it forgets where it came from as well as all data that was there. "


This is only partly correct. GOTO is control change, we use it to transfer program execution to another fixed point in our program, when we don't wish to return to the calling location.

The operation doesn't alter variables contents at all, although I seem to recall that DBpro still allows jumping between scopes, so jumping into a function from a global scope or from inside a function to some other point. Both could be potentially hazardous to your programs health.





Edit: Yep it still allows jumping between them, you'll notice when we jump between two different functions, the locals in the second function are effectively still the previous functions frame. So if you wrote to those variables you'd be writing to the previous function locals.. Which could some very undesirable results indeed.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 17th Nov 2014 18:41
Quote: "Both could be potentially hazardous to your programs health."


And your sanity. That's a great snippet.

I've seen people do things like that because they've forgotten they defined something as a function. One excellent reason for not using GOTO.



Powered by Free Banners
gamerboots
17
Years of Service
User Offline
Joined: 8th Dec 2008
Location: USA
Posted: 17th Nov 2014 20:13
Quote: "GOTO is control change, we use it to transfer program execution to another fixed point in our program, when we don't wish to return to the calling location."


I like this definition. It fits it quite well.

--------
DBP Archive
Kingius Returns
12
Years of Service
User Offline
Joined: 17th Oct 2013
Location: UK
Posted: 18th Nov 2014 09:31
Avoiding Goto stems from the 'Goto Statement Considered Harmful' letter from decades ago:

http://www.u.arizona.edu/~rubinson/copyright_violations/Go_To_Considered_Harmful.html

Login to post a reply

Server time is: 2026-07-17 12:28:28
Your offset time is: 2026-07-17 12:28:28