Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Type mismatch
Message
From
04/12/2001 07:43:59
 
 
To
04/12/2001 06:47:21
John Marrone
Bloodstock Research Inc.
Lexington, Kentucky, United States
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00589131
Message ID:
00589144
Views:
25
This message has been marked as the solution to the initial question of the thread.
Hi!

John, ALINES() always produce array of strings no matter what format string had. So you have to use the VAL() function:

REPLACE RaceNumber WITH val(aAr(3))

HTH.


>Here is the code for my problem. I create RaceNumber as N(2) in my create
>table command but I get a type mismatch when I go to replace it. I have been
>programming for many years (17) and I know this should be as simple as pie. I'm
>new to Foxpro though. Is it always going to be like this. I have heard good
>things about foxpro, but if something that should take seconds to do takes
>hours to get to work right I'm screwed.
>
>
>
>PROCEDURE ImportData
>LOCAL cFileName AS STRING, cCurDir AS STRING, vnRecCnt AS INTEGER
>LOCAL cStr AS STRING, nC AS INTEGER, nR AS INTEGER
>
>DIMENSION aAr(1,1435)
>
>IF FILE("testdbf.dbf")
>ERASE "testdbf.dbf"
>ENDIF
>SET NULL ON
>IF ! FILE("testdbf.dbf")
>CREATE TABLE TESTDBF ( RaceID C(13), ;
>RaceTrack C(3) , ;
>RaceDate C(8) , ;
>RaceNumber N(2) , ;
>RaceClass C(20) )
>ELSE
>SELECT 1
>USE TESTDBF ALIAS tes
>ENDIF
>cCurDir = myCurDir() && My own function
>CD download
>cFileName = GETFILE('MCP', 'Multicaps data file:', 'Open', 1, 'Select a Data File')
>* nHamdle is public, I will use it threwout the program since I only ever have
>* 1 file open at a time...
>nHandle = FOPEN(cFileName)
>nC = 1
>nR = 1
>DIMENSION aAr(1435)
>
>DO WHILE ! FEOF(nHandle)
>nR = nR + 1
>vcStr = FGETS(nHandle, 8192)
>vnRecCnt = ALINES(aAr, CHRTRAN(CHRTRAN(vcStr, ["], ""), ",", CHR(13)))
>APPEND BLANK
>REPLACE RaceID WITH IIF(LEN(ALLTRIM(aAr(1))) = 2,aAr(1) + "X",aAr(1)) + aAr(2) + TRANSFORM( aAr(3),"99")
>REPLACE RaceTrack WITH IIF(LEN(ALLTRIM(aAr(1))) = 2,aAr(1) + "X",aAr(1))
>REPLACE RaceDate WITH aAr(2)
>REPLACE RaceNumber WITH aAr(3)
>REPLACE RaceClass WITH aAr(11)
>@ 10,10 SAY "Record # " + STR(nR,3)
>ENDDO
>FCLOSE(nHandle)
>CD ..
>SELECT 1
>USE
>ENDPROC
>
>
>aAr(3) is a number. It is not a number in a string ie: "1".
>This should work. aAr(3) will never be empty either. The file looks like this:
>
>"AP ","20010708", 1, 1,,1540,"D",,"C","BUM","Clm 5000n1y",
>
>You can see the 3rd field is a numeric 1.
>
>I don't know what else to do.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform