Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem with ALLTRIM

Status
Not open for further replies.

Gilesy

Programmer
Jul 2, 2002
40
GB
Good morning all
I have an unusual problem with this code:

Where var = 4
STR(var) is returning " 4"
and bizarrely
ALLTRIM(STR(var)) is also returning " 4"
I am using this to construct a field name which subsequently crashes during EVALUATE because of the embedded spaces.
It only happens within the program, not in fox command. Is there an option setting that affects ALLTRIM??
[ponder]

Thanks

 
In what version and update level of FP DOS or Windows (or VFP) are you seeing this? Is 'var' a true memory variable, or a numeric field? (How is it defined?)

Rick
 
IF fld_type > 0
Ret_val = PADR(EVAL("ftable.ftype" + ;
ALLTRIM(STR(fld_type))),30)
ENDIF
RETURN ret_val

This is the code in question. There are 12 ftypes in the table. The fields are named ftype1 to ftype12, previous processing tells fld_type which we should be on.
So if fld_type is 6, this should do is evaluate what is in ftable.ftype6, but "ftable.ftype"+ALLTRIM(STR(fld_type)) is returning "ftable.ftype 6" - which is a crash!
It only does this in the program. In the command window it's fine.
 
1) What version and update level of FP DOS or Windows (or VFP) are you seeing this?
2) Have you tried:
Code:
IF fld_type > 0
    Ret_val = "ftable.ftype" + ALLTRIM(STR(fld_type))
    Ret_val = PADR(EVAL(Ret_val),30)
ENDIF
RETURN ret_val
EVAL() can sometimes confuse the code generation.

Rick
 
Try something like:

Ret_val = PADR(EVAL("ftable.ftype" - ;
ALLTRIM(STR(fld_type))),30)

(Note the '-')

-or-

ret_val = ALLTRIM(EVAL("ftable.ftype"))
ret_val = ret_val + ALLTRIM(STR(fld_type))
ret_val = PADR(ret_val, 30)

Break it down into individual parts and try it that way. Maybe it needs tweaking.


-Dave S.-
[cheers]
Even more Fox stuff at:
 
Thanks guys. It's Fox 2.6a windows by the way.

After a lot of experimenting we came up with this


Ret_val = PADR(EVAL("ftable.ftype" + ;
STR(fld_type,1,0)),30)

It works but God knows why the other didn't. And, the powers that be decreed that the ftypes above 9 have become redudant, which helped.

Cheers!
[cheers]
 
Hmmm, using FoxPro 2.6a for Windows I tried your original code (only substituting a variable for your table and field) both from the command prompt and within a simple program and it worked. Could it be something about the FoxPro installation at your site? Did you try it in another session after a reboot, or on another workstation?
 
Morning all.
We don't know what caused this - the original code from the command prompt works - always. Put inside some of our other applications - it works there too!
But put it into the program where it originally was and it refuses to work properly. That's why I wondered if there was a setting that did something peculiar and perhaps we had inadvertantly switched to in the program. Completly stumped us!
[curse]
But thanks for all your suggestions and comments, guys.
[cheers]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top