Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Creating a table, fieldnames in a list
Message
 
 
To
27/06/2012 16:31:02
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01547094
Message ID:
01547096
Views:
49
>Ok, apparently I have teh dumb today
>
>I'm trying to create a table structure in a program by building a list and then issuing the command
>Create table Table1 &FieldList
>
>and I keep getting a 'syntax error'.
>
>I'm building based of off values in a particular table column
>
>
>mflist = "'" + '(SCN C(7),'
>i = 1
>do while i <> 100
>  i = i + 1
>  if empty(idno)
>    skip
>    loop
>  endif
>  if i = 100
>    mflist = mflist + 'F' + alltrim(idno) + ' c(1))' + "'"
>  else
>    mflist = mflist + 'F' + alltrim(idno) + ' c(1), '
>  endif
>  skip
>enddo
>sele 0
>create table Table1 &mflist
>
>
>I'm putting an 'F' in front of the 'idno' fields because the value is a number (character)
>
>Now, I can go into the command window and say
>
>mflist = '(scn c(7), f200183 c(1), f9000091 c(1))'
>Create table Table1 &mflist 
>
> and it works just fine.
>
>Anyone see anything that I'm missing?

You don't need to add " in front and at the end, e.g. this works:
mflist = '(SCN C(7), '
i = 1
do while i <> 100
  i = i + 1
*!*     if empty(idno)
*!*       skip
*!*       loop
*!*     endif
  if i = 100
    mflist = mflist + 'F' + CAST(i as varchar(10)) + ' c(1))' 
  else
    mflist = mflist + 'F' + CAST(i as varchar(10)) + ' c(1), '
  endif
*  skip
enddo
select 0
=MESSAGEBOX(mfList)
lcComm = 'create cursor Table1 ' + mflist

_cliptext = m.lcComm
EXECSCRIPT(m.lcComm)
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform