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 / Uses for declaring a global string with a colon?

Author
Message
Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 14th Oct 2006 06:46 Edited at: 14th Oct 2006 06:46
I found this on the forum today. Why might declaring a global string with a " : " be useful. I understand how the colon works but I don't see how this can be applied.

Thank you.

http://forum.thegamecreators.com/?m=forum_view&t=75238&b=15

http://3dfolio.com
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Oct 2006 12:07
It was to allow strings of text to be easily manipulated. For example...

MyHour$ + cSEP + MyMinute$ + cSEP + MySecond$

would produce "10:23:46", for example. But the user could change the value of cSEP to "-", in order to set the disply format of the time to their preferences.



CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 14th Oct 2006 15:03
right, say you had ":" as a literal throughout your code, then, like Batty says, you wanted to change it to "-", you'd have to troll thru all of the code and change it manually. No big deal if its only there 5 times say. What if its there 100 times, or a 1000?
Using and alias like above or even a constant solves that problem, you can simply change the ONE definition of cSep and it will be reflected throughout the code.

Mistrel
Retired Moderator
19
Years of Service
User Offline
Joined: 9th Nov 2005
Location:
Posted: 15th Oct 2006 01:11
I understand. Thank you.

http://3dfolio.com

Login to post a reply

Server time is: 2024-11-27 05:52:03
Your offset time is: 2024-11-27 05:52:03