11.10.2025, 04:49 AM
Populate the UDT array once and store it as ASMDATA?
1. Write a simple application to populate your array of UDT's and PUT it to a binary file.
2. Create an ASMDATA block from the file - see below.
3. Paste the ASMDATA in your application
4. In your main application, DIM DoubleStarData(num_of_records) AT CODEPTR(myASMData)
1. Write a simple application to populate your array of UDT's and PUT it to a binary file.
2. Create an ASMDATA block from the file - see below.
3. Paste the ASMDATA in your application
4. In your main application, DIM DoubleStarData(num_of_records) AT CODEPTR(myASMData)
Code:
#COMPILE EXE "CreateASMDATA.exe"
#DIM ALL
FUNCTION PBMAIN() AS LONG
LOCAL sFileName, sTemp,SOut AS STRING
LOCAL sb,sb2 AS ISTRINGBUILDERA
LOCAL pB AS BYTE POINTER
sb = CLASS "StringBuilderA"
LOCAL ff, lLOF,x AS LONG
DISPLAY OPENFILE , , ,"Convert File To ASMDATA", "", "", "", "", 0 TO sFIleName
IF sFilename > "" THEN
ff = FREEFILE
OPEN sFIlename FOR BINARY AS #ff
lLOF = LOF(#ff)
GET$ #ff, lLOF,sTemp
CLOSE #ff
pB = STRPTR(sTemp)
sb.Capacity = lLOF + 50 ' allow for ASMDATA wrapper
sFilename = RETAIN$(PATHNAME$(NAMEX,sFileName), ANY CHR$(48 TO 57) + CHR$(65 TO 90) + CHR$(97 TO 122) + "_-") ' keep characters alowed for names
sb.Add "ASMDATA " & sFilename & " '" & STR$(lLOF) & " bytes" & $CRLF
sOut = "DB "
FOR x = pB TO pB + lLOF -1
sOut += FORMAT$(PEEK(x)) & ","
IF (x MOD 32) = 0 THEN
sOut = RTRIM$(sOut,",")
sb.Add sOut & $CRLF
sOut = "DB "
END IF
NEXT
IF sOut > "DB " THEN
sOut = RTRIM$(sOut,",")
sb.Add SOut & $CRLF
END IF
sb.Add "" & $CRLF & "END ASMDATA" & $CRLF
END IF
CLIPBOARD RESET
CLIPBOARD SET TEXT sb.string
? "ASMData " & sFilename & " placed on Clipboard."
END FUNCTION
'
--
New PowerBASIC User Community Forum:
https://pbusers.org/forum
New PowerBASIC User Community Forum:
https://pbusers.org/forum