Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
QBasic Random Data Files
Message
From
28/12/2000 13:43:19
 
 
To
28/12/2000 05:49:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00456801
Message ID:
00457470
Views:
33
Thanks, I will try these functions and see if it helps.

Ron


>Hi Martin,
>Isn't there a typo. AFAIK integers are stored as loworder, highorder bytes, meaning 16^0*1st+16^2*2nd... However there are cases this format is not obeyed like in fox headers.
>
>
**************************************************************************
>* getbyte : get a single byte at position specified by pos from a file opened
>*           with low level functions (handle comes from that function)
>* getword :
>* get a word size integer in hex format
>* parameters : handle - file handle got by fopen() or alike
>*              pos    - file position to get word
>*              lr     - (Logical) if .T. left-to-right format used
>*                       if .F. or not passed right-to-left format used
>*                       (more likely to be used with low level)
>* EXAMPLE :
>* getword(handle,12)     - returns 62313 if bytes at offset 11 are ( 69 F3 )
>* getword(handle,12,.T.) - returns 62313 if bytes at offset 11 are ( F3 69 )
>*
>* getlong : same as getword except gets 4 bytes
>**************************************************************************
>function getbyte
>parameters handle,pos
>=fseek(handle,POS,0)
>return asc(fread(handle,1))
>
>function getword
>parameters handle,pos,lr
>if parameters()<3
> lr=.f.
>endif
>=fseek(handle,POS,0)
>return asc(fread(handle,1))*iif(lr,256,1)+asc(fread(handle,1))*iif(lr,1,256)
>
>function getlong
>parameters handle,pos,lr
>if parameters()<3
> lr=.f.
>endif
>lowword=getword(handle,iif(lr,pos+2,pos),lr)
>highword=getword(handle,iif(lr,pos,pos+2),lr)
>return highword*65536+lowword
Cetin
>
>>Hi, Ronald.
>>
>>Integers are easy. Just take the two bytes, multiply the first by 256 and add the second. Same thing for longs. Floating point values are stores as base and mantissa. Just let me remember how it was. If I found a Basic at home tonight maybe I can do it.
>>
>>Til tomorrow!
>>
>>
>>>I have a project that I am working on converting a QBasic or Quick Basic program to VFP. The data files that are used are saved as random data files, so the numeric data is unreadable to VFP. I have found out that the numeric data is saved in this format:
>>>
>>> I = integers - stored as 2 bytes
>>> S = Single Precision - stored as 4 bytes
>>> D = Double Presision - stored as 8 bytes
>>> L = Long Integers - stored as 4 bytes
Previous
Reply
Map
View

Click here to load this message in the networking platform