Who would have thought that ADDBS('') would return the empty string, instead
of '\' !? This from VFP6 Help:

"Adds a backslash (if needed) to a path expression."

That was clear enough!

Re: surprising result from ADDBS('') by Jan

Jan
Tue Dec 11 22:33:02 PST 2007

Michael,

I guess "" (Empty string) is not a path expression. The code for addbs()
might read something like this:-
Parameters cPath
if empty(cPath)
return ""
endif
if !(right(cPath,1) = "\")
cPath = cPath + "\"
endif
return cPath


Just musing<g>
Jan

"Michael Asherman" <mda@nospam.com> wrote in message
news:%23V14$yHPIHA.5360@TK2MSFTNGP03.phx.gbl...
> Who would have thought that ADDBS('') would return the empty string,
> instead of '\' !? This from VFP6 Help:
>
> "Adds a backslash (if needed) to a path expression."
>
> That was clear enough!
>


Re: surprising result from ADDBS('') by Cy

Cy
Wed Dec 12 20:07:56 PST 2007

Michael Asherman wrote:
> Who would have thought that ADDBS('') would return the empty string, instead
> of '\' !? This from VFP6 Help:
>
> "Adds a backslash (if needed) to a path expression."
>
> That was clear enough!
>
>
That means that it adds a backslash "\" if the last character is not a
backslash. An empty string doesn't end in a backslash so it adds it.
You're misunderstanding the "if needed" part of the help description.

--
Cy Welch
Senior Programmer
MetSYS Inc
http://www.metsysinc.com

Re: surprising result from ADDBS('') by Cy

Cy
Wed Dec 12 20:09:41 PST 2007

Jan wrote:
> Michael,
>
> I guess "" (Empty string) is not a path expression. The code for addbs()
> might read something like this:-
> Parameters cPath
> if empty(cPath)
> return ""
> endif
> if !(right(cPath,1) = "\")
> cPath = cPath + "\"
> endif
> return cPath
>
>
> Just musing<g>
> Jan
>
> "Michael Asherman" <mda@nospam.com> wrote in message
> news:%23V14$yHPIHA.5360@TK2MSFTNGP03.phx.gbl...
>> Who would have thought that ADDBS('') would return the empty string,
>> instead of '\' !? This from VFP6 Help:
>>
>> "Adds a backslash (if needed) to a path expression."
>>
>> That was clear enough!
>>
>
I don't know the code, but affectively it behaves as you have described.
It ALWAYS adds a backspace to the end of the string if there is not
one already there. Even worse if you have a string with a backslash at
the end but it's blank padded it will add another because it only checks
the very last character.

--
Cy Welch
Senior Programmer
MetSYS Inc
http://www.metsysinc.com

Re: surprising result from ADDBS('') by Michael

Michael
Wed Dec 12 20:17:38 PST 2007

"Cy Welch" <cywelch@yahoo.com> wrote in message
news:u2j9%232TPIHA.5524@TK2MSFTNGP05.phx.gbl...
> Michael Asherman wrote:
>> Who would have thought that ADDBS('') would return the empty string,
>> instead of '\' !? This from VFP6 Help:
>>
>> "Adds a backslash (if needed) to a path expression."
>>
>> That was clear enough!
> That means that it adds a backslash "\" if the last character is not a
> backslash. An empty string doesn't end in a backslash so it adds it.
> You're misunderstanding the "if needed" part of the help description.
>
> --
> Cy Welch
> Senior Programmer
> MetSYS Inc
> http://www.metsysinc.com

Cy,

Maybe I wan't clear enough. You are mistaken, I believe. Try it yourself -
ADDBS does *not* add a backslash to the empty string. I agree that one
would expect it never to return the empty string. That was my point!

Mike



Re: surprising result from ADDBS('') by Olaf

Olaf
Thu Dec 13 03:40:34 PST 2007

> Cy,
>
> Maybe I wan't clear enough. You are mistaken, I believe. Try it
> yourself - ADDBS does *not* add a backslash to the empty string. I agree
> that one would expect it never to return the empty string. That was my
> point!

Well, still the argument holds true.

ADDBS() is made for paths.

No BS is needed for an empty path = no path.
This would make the empty path the current Dir path,
which would be something totally different.

Bye, Olaf.



Re: surprising result from ADDBS('') by Rush

Rush
Thu Dec 13 07:47:42 PST 2007

Olaf Doschke wrote:
>> Cy,
>>
>> Maybe I wan't clear enough. You are mistaken, I believe. Try it
>> yourself - ADDBS does *not* add a backslash to the empty string. I agree
>> that one would expect it never to return the empty string. That was my
>> point!
>>
>
> Well, still the argument holds true.
>
> ADDBS() is made for paths.
>
> No BS is needed for an empty path = no path.
> This would make the empty path the current Dir path,
> which would be something totally different.
>
> Bye, Olaf.
>
>
>
I think you meant that the empty path (when BS'ed) would be the root
dir? (Instead of the current one).

- Rush

Re: surprising result from ADDBS('') by Michael

Michael
Thu Dec 13 07:48:57 PST 2007

"Olaf Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU@strconv.14.de> wrote in
message news:uoVAJzXPIHA.4684@TK2MSFTNGP06.phx.gbl...
>> Cy,
>>
>> Maybe I wan't clear enough. You are mistaken, I believe. Try it
>> yourself - ADDBS does *not* add a backslash to the empty string. I agree
>> that one would expect it never to return the empty string. That was my
>> point!
>
> Well, still the argument holds true.
>
> ADDBS() is made for paths.
>
> No BS is needed for an empty path = no path.
> This would make the empty path the current Dir path,
> which would be something totally different.
>
> Bye, Olaf.
>

Olaf,

That's an interesting rationalization, but consider the case of a path like
"C:", for which ADDBS would return "C:\". By the same token, these might be
totally different directories or they might be the same, depending on what
is your current directory. Obviously the problem is the incredibly vague
phrase "if needed", which has no place in Help documentation, IMO. Anyway,
the reason I brought it up was to warn others about this highly non-obvious
pitfall. I'll bet that the majority of VFP programmers, if asked what
result they would expect from ADDBS(''), would unhesitatingly answer '\',
unless they learned this one the hard way.

Mike



Re: surprising result from ADDBS('') by Olaf

Olaf
Thu Dec 13 10:12:45 PST 2007

> I think you meant that the empty path (when BS'ed) would be the root dir?
> (Instead of the current one).

well, I really don't know what the meaning of the
empty path should be. I'd say it should be like NULL,
meaning nowhere, no valid path, like DIRECTORY("")
returns .F.

On the other side, vfp handles FILE("text.txt") in
searching text.txt in the current dir (besides other
directories it will search afterwards) and does not
need ".\text.txt" as argument to do so. Taking this into
account, ADDBS("") should return the curdir, but that
would be quite outside of the definition to add a
backslash to a path if needed.

@Michael:
Also C: can't be a subdirectory, as : is'nt allowed
in file or folder names.

Bye, Olaf.






Re: surprising result from ADDBS('') by Gene

Gene
Thu Dec 13 10:30:17 PST 2007

"Michael Asherman" <mda@nospam.com> wrote:

[snip]

>That's an interesting rationalization, but consider the case of a path like
>"C:", for which ADDBS would return "C:\". By the same token, these might be
>totally different directories or they might be the same, depending on what
>is your current directory. Obviously the problem is the incredibly vague
>phrase "if needed", which has no place in Help documentation, IMO. Anyway,
>the reason I brought it up was to warn others about this highly non-obvious
>pitfall. I'll bet that the majority of VFP programmers, if asked what
>result they would expect from ADDBS(''), would unhesitatingly answer '\',
>unless they learned this one the hard way.

You want quality documentation? You got it!

addbs() takes a string and returns it usually lengthened by
adding BS. If the string already has enough BS, more is not added.
addbs("If I am elected")
obviously needs more BS, and sure enough, more is added.

Next on Silly Names: The CDP 1802 CPU's SEX instruction

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:
I have preferences.
You have biases.
He/She has prejudices.

Re: surprising result from ADDBS('') by Cy

Cy
Thu Dec 20 00:04:42 CST 2007

Michael Asherman wrote:
> "Olaf Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU@strconv.14.de> wrote in
> message news:uoVAJzXPIHA.4684@TK2MSFTNGP06.phx.gbl...
>>> Cy,
>>>
>>> Maybe I wan't clear enough. You are mistaken, I believe. Try it
>>> yourself - ADDBS does *not* add a backslash to the empty string. I agree
>>> that one would expect it never to return the empty string. That was my
>>> point!
>> Well, still the argument holds true.
>>
>> ADDBS() is made for paths.
>>
>> No BS is needed for an empty path = no path.
>> This would make the empty path the current Dir path,
>> which would be something totally different.
>>
>> Bye, Olaf.
>>
>
> Olaf,
>
> That's an interesting rationalization, but consider the case of a path like
> "C:", for which ADDBS would return "C:\". By the same token, these might be
> totally different directories or they might be the same, depending on what
> is your current directory. Obviously the problem is the incredibly vague
> phrase "if needed", which has no place in Help documentation, IMO. Anyway,
> the reason I brought it up was to warn others about this highly non-obvious
> pitfall. I'll bet that the majority of VFP programmers, if asked what
> result they would expect from ADDBS(''), would unhesitatingly answer '\',
> unless they learned this one the hard way.
>
> Mike
>
>
Your right as it didn't add a backslash to the empty string. And
contrary to what I remember, it doesn't pay attention to trailing spaces
either.

--
Cy Welch
Senior Programmer
MetSYS Inc
http://www.metsysinc.com