Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
MKSMBF$, MKDMBF$ Functions Programming Example
◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
'This example uses the MKSMBF$ function to store real values in a file as
'Microsoft-Binary-format numbers.
'Read a name and a test score from the console.
'Store as a record in a random-access file.
'Scores are written out as
'Microsoft-Binary-format single-precision values.
TYPE Buffer
NameField AS STRING * 20
ScoreField AS STRING * 4
END TYPE
DIM RecBuffer AS Buffer
OPEN "TESTDAT.DAT" FOR RANDOM AS #1 LEN=LEN(RecBuffer)
PRINT "Enter a name and a score, separated by a comma."
PRINT "Enter 'END, 0' to end input."
INPUT NameIn$, Score
I=0
'Read pairs of names and scores from the console
'until the name is END.
DO WHILE UCASE$(NameIn$) <> "END"
I=I+1
RecBuffer.NameField=NameIn$
'Convert the score to a string.
RecBuffer.ScoreField=MKSMBF$(Score)
PUT #1,I,RecBuffer
INPUT NameIn$, Score
LOOP
PRINT I;" records written."
CLOSE #1