Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Table
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Re: Table
Miscellaneous
Thread ID:
00453520
Message ID:
00453532
Views:
13
>Hi Everyone:
> I want to create a table with 32 fields in a tabel. The number of fields in a table could be varry. I am using a For loop to do this,however, it is not working. Can someone please tell me what I am doing wrong?
>
>**Code
>CREATE TABLE salesman ;
> For i = 1 to lnCount && lnCount has the number of fields in a given table.
> ('Field' + Str(i) c(20))
> EndFor
>
>Thanks
>MA

MA,
Build the string first and then use macro substitution to issue it.
lcstring = [CREATE TABLE salesman (]
For ii = 1 to lnCount && lnCount has the number of fields in a given table.
   lcstring  = lcstring + ['Field' ] + transform(i) + [ c(20),]
   if ii = lncount then
      * strip off last ","
      lcstring = left(lcstring,len(lcstring)-1)
   endif
EndFor

* add trailing parenthesis for Create Tabel command
lcstring = lcstring + [)]
&lcstring
You may have to tweak this as I did not test it.

HTH.
Larry Miller
MCSD
LWMiller3@verizon.net

Accumulate learning by study, understand what you learn by questioning. -- Mingjiao
Previous
Reply
Map
View

Click here to load this message in the networking platform