Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Create cursor, where no fields is dynamic
Message
From
18/08/2000 12:34:24
 
 
To
18/08/2000 12:16:10
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00406720
Message ID:
00406729
Views:
29
>Is it possible to create a cursor with a variable number of fields, i.e. cursor has 3 constant fields,
>a,b,c, and fields f1 to fn where "n" is determinted when program is run?

Yes. 2 ways
** method 1, e.g.
lcCreate = "CREATE CURSOR cuMyCursor (cfixed1 c(10), nfixed2 n(5,2)"
FOR ji = 1 TO 3
  ** this loop will need more dynamic determination of data type
  lcField = "cnew" + ALLTRIM(STR(ji))
  lcType = "c(10)"
  lcCreate = lcCreate + ", " + lcField + " " + lcType
ENDFOR
lcCreate = lcCreate + ")"
&lcCreate

** method 2, create cursor and add to it
CREATE CURSOR cuMyCursor (cfixed1 c(10), nfixed2 n(5,2))
FOR ji = 1 TO 3
  lcField = "cnew" + ALLTRIM(STR(ji))
  lcType = "c(10)"
  ALTER TABLE cuMyCursor ADD COLUMN &lcField &lcType
ENDFOR
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform