Advantages of $?

C

cmdex_VABCH

I have recently taken over a number of Access databases. The previous
developer used the $ symbol randomly for functions or thier arguments. I
remember reading about the differance between using the $ symbol and not
using it, however that was years ago. I have been searching the web for a
reason to use this notation or not to use it, but without any success.
Access' Object browser lists both ways, but the help file only gives the
detail for the member without the symbol. ex.: Function CurDir([Drive]) vs.
Function CurDir$([Drive]) As String

If I haven't confused you yet, please direct me to documentation on the
purpose of this symbol. I personally do not see a reason for it's use. I
need some justification.

Thank you.
chris
 
A

Albert D. Kallal

The use of the $ sign goes back quite a ways in the "basic" programming
language.

In fact it's used predates "visual" basic.

Their is somewhat of a difference in the use of the two, when you use the
dollar sign, it represents a function that will *always* return a string
data type.

Remember when you use a string data type function, it is not possible for
that function to return a null value. It can most certainly return a zero
length string or a string denoted such as ""

For most code doesn't make a lot of difference, but for the last many years
I've not use the dollar sign notation anymore.

here is a quick example showing the significance of the difference, you can
try typing the following into the debug window.

? left$(null,1)

If you try the above, remember the left function will have to return a
string data type, and the above sample code will cause an execution error.

However, the following code will not error

? left(null,1)

So the above function is capable of accepting an null value as an parameter,
and also returning a null value. Because often are data is derived from SQL
code, which also means you be dealing with nulls, then as a general rule
I've dropped the dollar sign.

Furthermore any issues of performance are pretty much moot since we have
nearly unlimited amounts of processing in computers today. And, in average
applications we are only running a few hundred lines of code at one given
time anyway. To be honest, I suspect there might be a slight performance
advantage to using the dollar sign, but I'm not aware of it.

About the only reason I would continue using the dollar sign in this
existing application is one for consistency, it would be rather strange to
read a bunch of code, then see half of it using dollar signs, and the other
half not.

So, out of respect to the original coding standards used or just simply the
coding style used, I would actually for that one application continue to be
consistent, and continue to use the dollar sign just out of respect only
simply for the fact that's the way they did it.
 
S

Stuart McCall

I suspect there might be a slight performance advantage to using the
dollar sign, but I'm not aware of it.

Back in A97 I ran some comparison tests and found that functions with the $
worked faster with strings than with variants. Vice versa for the functions
without $.

But the speed difference was minute, even over 500,000 iterations. And as
you say, the processing power we now possess makes this a mute point.

But I still find myself using $ with strings. Old habits die hard :)
 
T

Tony Toews [MVP]

Albert D. Kallal said:
In fact it's used predates "visual" basic.

I was using it on IBM 5110 micro computer in 1979. Basic was loaded
in 32 kb ROM and the program space was a whopping 32 Kb RAM. 16 x 64
character screen, 2 * 8" floppies and a 120 cps dot matrix printer set
you back $25K. See photo at
http://www-03.ibm.com/ibm/history/exhibits/pc/pc_4.html

But we never had a system with the tape drive. That was only needed
for dealing with the 5100 which was tape drive only.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
T

Tony Toews [MVP]

Stuart McCall said:
I did <g>. But thinking about it, it's not bad as it stands: a point that
says nothing worth knowing.. :)

<chuckle> Good point.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
C

cmdex_VABCH via AccessMonster.com

Thank you Albert and Tony. Very helpful and informative. I love the IBM
archives page. Now I remember why I used to think that computers were a
waste of time. :) Now I make a living with application developement. Go
figure!!!
 
G

Guest

David W. Fenton said:
I think you mean "moot point."

Maybe he means "moo point"

"It's like a cow's opinion. Y'know. It just doesn't matter. It's moo." -
Joey from "Friends"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top