Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global count
Message
From
07/02/2012 19:09:32
 
 
To
07/02/2012 09:19:40
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
01534489
Message ID:
01534805
Views:
60
Being that brevity is the soul of wit and that i know you like a challenge i came up with the number two. Of course i think Shakespeare was making reference to a mad man (Hamlet) when he coined that phrase.

thank you all for the discussion - the solution is holding up well.

karen


>>>>>If the table is a dbf and not too big:
>>>>>lcData=Filetostr('timep.dbf') 
>>>>>lnCount=Occurs('|',lcData)
>>>>>
>>>>>>I have 250 records in a database called timep.
>>>>>>Each record has 100 ds called p1,p2,p3 ..... p100
>>>>>>
>>>>>>Is there a global search i can do for a tally of the numbers of times the symbol "|" appears in the whole database - without having to count through each field of each record - ie without using scan or for-endfor. ie one or two lines of code.
>>>>>>
>>>>>>thanks for any suggestions
>>>>>>k
>>>>
>>>>
>>>>Maybe I'm wrong, but is this will accurate if the value "|" (0x7C or 124 decimal) appear in .DBF header?
>>>>
>>>>I think this code below will prevent that case
>>>>
>>>>
>>>>lcData=FILETOSTR("timep.dbf")
>>>>
>>>>*!* skip until first record
>>>>lnFirstRecordOffset = CTOBIN(SUBSTR(m.lcData, 9, 2), "2RS")
>>>>
>>>>lnCount=OCCURS("|", SUBSTR(m.lcData, m.lnFirstRecordOffset + 1))
>>>>
>>>
>>>Yes, I know, but karen wanted a maximum of two lines of code. :-)
>>
>>
>>As Sergey reply, your sample and my addition can't solve the real problem, in case if any numeric field / value in the records.
>>:D
>
>My first idea was something like
>Select * from timep.dbf into file somereallystupidname.txt plain
>lcData=filetostr('somereallystupidname.txt')
>lnCount=occurs('|',lcData)
>eras somereallystupidname.txt
>But that would leave the table open, and consume four lines of code (five if you close the table afterwards). However, in this case the client wanted maximum two lines of codes, and it's always the client who defines the conditions. :-)
Previous
Reply
Map
View

Click here to load this message in the networking platform