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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DO uppercase program Help

Status
Not open for further replies.

Idokyoku2

Technical User
May 16, 2004
57
US
Hello,
I'm looking to create a program to convert from lower to uppercase for all fields. I'm using some knowledge obtained in SQL to create this, and that is obviously why I need help. It compiles properly, not sure if everything would compile regardless of whether it works or not.

Here it is:
* This is to convert all lowercase to uppercase
DO uppercas
CASE
WHEN () 'a' THEN 'A'
WHEN () 'b' THEN 'B'
WHEN () 'c' THEN 'C'
and so on through the alphabet
END CASE
END;

I'm getting a couple of error messages like-"Allowed DO nesting level exceeded" and "Command is missing required clause" and the las being, of course, "Syntax Error."

I would truly appreciate any help as this is my first .prg
Thanks,
David
 
Does this help out?

Code:
myScope = "ALL"  && empty this string if working only on the current record
FOR X = 1 TO FCOUNT()
   xField=FIELD(x)
   IF TYPE(xField)="C"
      * this example changes only character fields
      * do you have memo fields?
      REPLACE &myScope (xField) WITH UPPER(xField)
   ENDIF
NEXT
dbMark
 
David,
FoxPro just uses the UPPER() (and LOWER()) function to do this for you. If you've got some special handling requirements, check out the CHRTRAN() function.
Code:
REPLACE all NAME with UPPER(NAME)

Rick
 
Thanks for the quick posts!

dbMark,
I'm not quite sure why your code isn't working for me, bu t Rick's post worked fine. I probably don't even need to create a program for this. I thought I'd need one since that is what we use (a canned .prg) back in data processing.

I mostly use dbase during my limited use and should have thought of that myself, instead of complicating things.

I truly thank both you for your quick response.
Have a great weekend!
David
 
Oh, are you using dBase? Then, yes the code needs some adjustment. The code I wrote should have worked in Visual FoxPro. Rick's code will work with either language but did not address the replacement of all fields in the table.

Change this line:

REPLACE &myScope (xField) WITH UPPER(xField)

To:

REPLACE &myScope &xField WITH UPPER(xField)

Although I'm not sure about newer dBase versions, versions of dBase up through 5.0 had to use macrosubstitution where VFP allowed that or evaluation.
 
It is mostly dbase, but this time it's VFP. My boss seems to be stuck on dbase. However, I've just recently notice how much more superior VFP is. Especially, regarding some SQL capabilities, etc.

Thanks a bunch.
David
 
David,

I've just recently notice how much more superior VFP is.

Having used both dBASE (all versions) and FoxPro (all versions) extensively, I totally agree with that statement. In fact, VFP is so far ahead of dBASE that the latter pales to nothing in the comparison. You can tell your boss that from me.

Mike


Mike Lewis
Edinburgh, Scotland

My Visual Foxpro web site: My Crystal Reports web site:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top