04-26-2022, 03:16 PM
(This post was last modified: 04-27-2022, 11:44 AM by James D Jarvis.
Edit Reason: typos
)
This is great. looking forward to the related programs. I wanted to use a method like this for using sounds files to embed them in a program, extract them to a temporary directory and play them from there, but hadn't gotten to there yet.
Using the created (converted) files is very simple. Here's an program I made reading a small text file made with notepad and just reworking the file created in BASFILE.
Using the created (converted) files is very simple. Here's an program I made reading a small text file made with notepad and just reworking the file created in BASFILE.
Code: (Select All)
'an example program that uses Dav's Basfile
Print unpackstring$
thestring:
Data ""
Data "hailDQbC\H5:9e::AQ<cCQ4E8]<c9E5B>aLb9eDD8h4c]PLBE_BZX4mhU[lb"
Data "_L5lDQ4cEQlb74G##0PH%%L2"
Data "/END"
' i added /END as a flag, I use it a lot for reading string data of variable length with the read statment
Print BASFILE$
Function unpackstring$
a$ = ""
Restore thestring
Do
Read in$
a$ = a$ + in$
Loop Until InStr(in$, "/END") 'stop at the endflag for the flag
a$ = Left$(a$, (Len(a$) - 4)) 'take the endflag out of the string
btemp$ = ""
For i& = 1 To Len(a$) Step 4: B$ = Mid$(a$, i&, 4)
If InStr(1, B$, "%") Then
For C% = 1 To Len(B$): F$ = Mid$(B$, C%, 1)
If F$ <> "%" Then C$ = C$ + F$
Next: B$ = C$: End If: For j = 1 To Len(B$)
If Mid$(B$, j, 1) = "#" Then
Mid$(B$, j) = "@": End If: Next
For t% = Len(B$) To 1 Step -1
B& = B& * 64 + Asc(Mid$(B$, t%)) - 48
Next: X$ = "": For t% = 1 To Len(B$) - 1
X$ = X$ + Chr$(B& And 255): B& = B& \ 256
Next: btemp$ = btemp$ + X$: Next
unpackstring$ = _Inflate$(btemp$): btemp$ = ""
End Function