Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Binary routine for FoxPro 2.5 DOS
Message
De
05/09/2000 07:47:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
05/09/2000 05:45:50
Information générale
Forum:
Visual FoxPro
Catégorie:
FoxPro 2.x
Divers
Thread ID:
00412373
Message ID:
00412392
Vues:
18
>I need some information / examples on how to create a binary file that I can load and call using the LOAD and CALL statements.
>
>Thanks
>
>Anurag


Anurag,
Bin files are simple .com files. Data is passed to DS:BX and return value is also placed in DS:BX. There are some precautions about using it which you can follow in help file. Here is a sample returning disk serial number (format assigned serial number) :
* ASM code
.MODEL LARGE
.CODE
        Org 0h                ; FP needs bins absolutely execute from address 0
main:
        push bx               ; save bx
        mov ax,6900h          ; get disk serial number function
        mov dx,bx             ; our return buffer offset
        mov bx,ds:[bx]        ; drive passed as parameter
        int 21h               ; execute dos interrupt
        pop bx                ; restore bx
        retf                  ; return far to FP
        end main
This is Turbo assembler code. I have this .bat file I use to convert to .bin :

tasm %1
tlink %1
exe2bin %1.exe %1.bin
del %1.map
del %1.exe
del %1.obj

And here is foxpro code using it :
parameters driveletter
set talk off
clear
mp = chr(asc(upper(driveletter))-ASC("A")+1)+chr(0)+;
        space(22) && 24 bytes total
load serial
call serial with mp                                 && execute asm
? substr(mp,2+1) && First two bytes are always chr(0)
cSerial1 = substr(mp,1+2,1)
cSerial2 = substr(mp,2+2,1)
cSerial3 = substr(mp,3+2,1)
cSerial4 = substr(mp,4+2,1)

? asc(cSerial4)  && Disk serial number
? asc(cSerial3)  && is a doubleword
? asc(cSerial2)  && So read in reverse order
? asc(cSerial1)  && as shown in dir
* Now print in hex format just like dir
? "Disk serial number is "
?? padl(dec2hex(asc(cSerial4)),2,"0")
?? padl(dec2hex(asc(cSerial3)),2,"0")
?? ":"
?? padl(dec2hex(asc(cSerial2)),2,"0")
?? padl(dec2hex(asc(cSerial1)),2,"0")
?

function Dec2Hex
parameters nDecimal
n=0
do while floor(nDecimal/16^n) > 15
 n = n+1
enddo
cHEX = ""
for ix=n to 0 step -1
        cHEX = cHex + DecDigit2HexDigit(floor(nDecimal/16^ix))
        nDecimal = nDecimal % 16
endfor
return cHex

function DecDigit2HexDigit
parameters nDecimal
return iif(ndecimal>9,chr(asc("A")+nDecimal%10),str(nDecimal,1))
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform