Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Functions

0 views
Skip to first unread message

Raymond Pender Chapman

unread,
Aug 1, 2001, 12:27:08 PM8/1/01
to
in my reading of the vdb7.5 pdf manual I have come across several
language functions
like LEFT() and left() and a few others. What is the difference? They
both do the same thing from my understanding. Is their any programmatic
benefit from using one or the other?

Howard Mintzer

unread,
Aug 1, 2001, 1:01:40 PM8/1/01
to
in the olh for left()

Other than the syntactic difference of being a method instead of a
function, this method behaves identically to the LEFT( ) function.

To use the left() method you need to do this:
c=new string('raymond')
? c.left(2) would give you ra

on the other hand if you're dealing with a string that you haven't made an
object (memeber of the string class) you might say
c='raymond'
? left(c,2) would give you ra

the difference is when you create a string object it encapuslates the value
of the string and you can then use dot notation to access it's methods
(which are similar to string functions). In some cases it makes a
difference, you might be able to do things with the method that you can't
as easily do with the string functions. I usually use the functions tho in
a recent application i played around with the methods and they were easy to
use and easier logic to follow in my code.

Another thing with SOME string methods is that they are zero based instead
of one based. For instance
c='raymond'
substr(c,1,1)='r'

however
c=new string('raymond')
c.substring(1,1)='a' because the string starts at zero c.substring(0,1)='r'

Hope this helps a little, perhaps someone who knows alot more about this
than I can explain more if you need it.

Ken Mayer [dBASE, Inc.]

unread,
Aug 1, 2001, 1:22:24 PM8/1/01
to

As Howard points out, they are quite similar. The lower case version
references a method of a class; the upper case version references a
language FUNCTION.

One thing that I don't think Howard may even realize, is that you can
bypass creating an instance of the string object, and just use the
methods directly on a string:

? "Raymond".left(2)
// will return "Ra"
cName = "Raymond"
? cName.left(2)
// will also return "Ra"

Etc.

The string class methods work on literal strings, and pretty much
anywhere a string exists. Another example:

form.rowset.fields["First Name"].value.left(2)

Will also work (I use this periodically for some of my own code <G>).

Ken
---
Ken Mayer [dBASE, Inc.]
** Please respond ONLY in the newsgroups **

"Think OOP"

dBASE, Inc. website: http://www.dbase.com

Raymond Pender Chapman

unread,
Aug 1, 2001, 3:07:35 PM8/1/01
to
thanks Ken & Howard I'm beginning to understand ,starting to see a few new
ways to implement a few ideas.

>

Howard Mintzer

unread,
Aug 1, 2001, 9:09:26 PM8/1/01
to
0 new messages