Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using VAL() and INSERT INTO with array of objects
Message
From
03/02/2004 11:14:25
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Using VAL() and INSERT INTO with array of objects
Miscellaneous
Thread ID:
00873420
Message ID:
00873420
Views:
75
Hi,

I'm trying to use the code listed below in VFP 8.1. I want to loop through an array of objects called oRace(n) using the nCount variable which is counting the steps of the loop; then check the TYPE() of the data in each oRace(n).currentraceid, and if it is not a Numeric data type use VAL() to change it into a Numeric, before finally using INSERT INTO to put it into a table field that is expecting to receive a Numeric.

Unfortunately I get an error on the STORE VAL() line. I tried taking this out & go straight to the INSERT INTO line but that throws an error too. So I am wondering if I have got my syntax all wrong here, which is why I am kind of asking two questions in one. Is the way I am trying to use oRace(nCount).currentraceid with these two commands valid?

*****
FOR nCount = 1 TO numberofpeopletoday

IF !TYPE('oRace(nCount).currentraceid') = "N"
STORE VAL(oRace(nCount).currentraceid) TO oRace(nCount).currentraceid
ENDIF

INSERT INTO current (craceid) VALUES (oRace(nCount).currentraceid)

NEXT
*****

oRace(n) is an array of objects that each have properties, e.g. there are objects oRace(1) through oRace(100), and each has a few properties such as oRace(n).currentraceid, oRace(n).currentracedate, etc. When I check in the debugger the oRace(n).currentraceid is a number just like it should be, and has a data type of N, which makes me wonder if the If !TYPE() line is correct. But even if I take that IF...ENDIF block out and just run the INSERT INTO line, it throws an error top. This is despite that data being type N and the table field created to receive numeric data using CREATE TABLE current (craceid n(6,2))


Thanks in advance for your help,

Paul
Next
Reply
Map
View

Click here to load this message in the networking platform