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 / AS..... why?

Author
Message
zzabb
21
Years of Service
User Offline
Joined: 25th Apr 2003
Location: Seattle, USA
Posted: 18th Sep 2003 02:31
I’ve noticed that some people are declaring their variables in the code they post
As interger
As float
As……

Does this make DBPro or DBReg more stable?
Is this a hold over from other programming languages?
I guess I’m asking why? because i don't see it in the DB documentation

My advice is free -
unfortunately you get what you pay for (-:
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Sep 2003 02:52
I guess that it's a personal thing.

I prefer to do it that way because it's the way it's done in the other languages that I use. Only BASIC has that wierd extra character at the end of the variable name that defines its type ($ or #)
zzabb
21
Years of Service
User Offline
Joined: 25th Apr 2003
Location: Seattle, USA
Posted: 18th Sep 2003 03:05
ok thanx

i just wondered cause it seems at times DBPro forgets variable info, so i wondered if it made it a little more stable

My advice is free -
unfortunately you get what you pay for (-:
MicroMan
21
Years of Service
User Offline
Joined: 19th Aug 2003
Location: Stockholm, Sweden
Posted: 18th Sep 2003 04:55
It's just a habit. I'm used to it from Visual Basic because there I have to declare each variable, and I've carried the habit over to Dark Basic Pro.

Besides, I think it makes for more readable code, and it's important to understand what the code is doing even after six months.

-----
They SAID that given enough time a million monkeys with typewriters could recreate the collected works of William Shakespeare... Internet sure proved them wrong.
-----
zzabb
21
Years of Service
User Offline
Joined: 25th Apr 2003
Location: Seattle, USA
Posted: 18th Sep 2003 06:10 Edited at: 18th Sep 2003 06:12
its only more readable if you know what it means (-:

i'm not that bright
i haven't learnt any other programming than DB
i've only been using it for a few months
I’m 39yrs old
I thought pong was cool (when it came out)

(trying to think of excuses for why it took me a couple hours to figure out what it meant (-: )

My advice is free -
unfortunately you get what you pay for (-:
zzabb
21
Years of Service
User Offline
Joined: 25th Apr 2003
Location: Seattle, USA
Posted: 18th Sep 2003 06:14
MicroMan
your tag line is great (-:

My advice is free -
unfortunately you get what you pay for (-:
PenguinPaws
21
Years of Service
User Offline
Joined: 11th Sep 2003
Location:
Posted: 18th Sep 2003 18:06 Edited at: 19th Sep 2003 01:14
I use the Variable AS DataType because I prefer hungarian notation (prefixes before variable name) to show what type of variable I am using. It makes it easier for me to type the variable names and I don't have to remember what symbol goes with what data type.

Example:
Local iVariable as integer
Local fVariable as float
Local tVariable as string
(I use 't' because I use 's' for single in VB )
Etc.

I also like to know what variables I am using in a certain part code. It helps me keep the number of variables I am using down. I also like to create reusable variables for counters and temp. variables and such. I am always creating an 'i1 as integer' variable that I reuse for counters and momentary flags. If I know what variables I have already created I can reuse them.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 18th Sep 2003 19:15 Edited at: 18th Sep 2003 19:16
I agree with MicroMan and PenguinPaws, I am a vb6/vb.net programmer and I think it makes DBP more readable, and it is required in VB. I also use hung-notation but the three letter form...

intMyVariable as Integer
strMyOtherVariable as String

everyone has their own way which is fine but hopefully the programming newbies will get some good habits, so when we try to help them we can more easily read their code

-RUST-

Login to post a reply

Server time is: 2024-09-21 00:59:29
Your offset time is: 2024-09-21 00:59:29