Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How does one determine if a value is a true INTEGER?
Message
From
20/10/2000 09:02:15
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
20/10/2000 08:26:04
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00431993
Message ID:
00432040
Views:
38
>>Hi Peter,
>>
>>You could check each set of data and see if it contains an (.). If not then it's an integer.
>>
>>
>>
>>>Here´s the scenario:
>>>
>>>Reading a CSV/TXT file, I receive "1000","2.541","2000","2000.00"
>>>
>>>The rule says if the value of the string is a true integer (2000), divide it by 100, otherwise (2000.00) leave it as it is.
>>>
>>>Since VFP evaluates 1=1.000 to true, a simple ? INT(VAL(lcValue))=VAL(lcValue) is not very helpful.
>>>
>>>I´ve come up with
>>>
>>>lnValue=IIF("." $ lcValue,VAL(lcValue),VAL(lcValue)/100)
>>>
>>>Which works, of course, except it´s sooo sloooow!
>>>
>>>If there is a better (much much faster) way please let me know!
>>>
>>>TIA
>
>Yes, Benn, I´d thought I´d indicated that that´s what I´m doing.
>Am I missing someting here?
>
>And how are you, by the way?
>
>Cetin: I dont see how loading the stuff into a cursor would help, since one, unless I´m very much mistaken, has to ask the exact same question in one form or another. In addition to that you´d have to walz through the file, non?
>
>There´s gotta be a better way.

Peter,
You would ask the same question yes but to a faster replier. A temporary cursor at least doesn't have indexes which slows down append, you don't need lowlevel parsing and inserting another.
As a same question much different reply times sample you could try this :
dimension aTest[50000]
aTest = 'A'
*1st
lcReply = ''
for ix=1 to 50000
 lcReply = lcReply + aTest[ix]
endfor

*2nd
handle=fcreate('temp.tmp')
for ix=1 to 50000
 =fwrite(handle,aTest[ix])
endfor
lnSize=fseek(handle,0,2)
=fseek(handle,0,0)
lcReply = fread(handle,lnSize)
=fclose(handle)
erase temp.tmp
2nd is longer in lines but speed ? A simple test like this wouldn't mean there is a better way for you but might be, hopefully.

If you provide a small portion of text file + code you use to get it then better alternatives might be found.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform