Is it possible to Load/Modify/Save an IFF-Config-File like wbpattern.prefs with Hollywood or have i to invent my own Load/Modify/Save-Code?
If i understand that's correctly, It's organisated in so called IFF-Chunks. Something from the old 68000 days with even- and odd-startpoint-adresses inside the IFF-Structure, depending on the length of the string to be written.
Can someone provide informations how it excatly works?
Load/Modify/Save IFF-Config-File
Re: Load/Modify/Save IFF-Config-File
Here is smtg for a start:
You have to know the internal structure of each chunk.
You have to know the internal structure of each chunk.
Code: Select all
;extracts the chunk structure as follows:
; form.type - eg. ilbm or dr2d
; form.size - full size of the form
; form.chunks - list with the chunk details
; form.chunks[n].name
; form.chunks[n].size
; form.chunks[n].offset - offset from the beginning of the file/bank
Function form_unpack(f$)
Local _form={}
Local l,fh
l=FileSize(f$)
fh = OpenFile ( Nil , f$ )
_form.bank=AllocMem(nil,l)
ReadMem(fh,_form.bank,l)
CloseFile(fh)
If Peek(_form.bank,0,#STRING,4)="FORM"
Local offset=4
Local chunk={}
_form.size=Peek(_form.bank,offset,#INTEGER)
offset=offset+4
_form.type=Peek(_form.bank,offset,#STRING,4)
offset=offset+4
_form.chunks={}
While offset < _form.size+8
chunk.name=Peek(_form.bank,offset,#STRING,4)
offset=offset+4
chunk.size=Peek(_form.bank,offset,#INTEGER)
offset=offset+4
chunk.offset=offset
offset=offset+((chunk.size+1) & $FFFFFFFe)
InsertItem(_form.chunks,copytable(chunk))
Wend
Return(_form)
ElseIf
DebugPrint("No form at start!")
EndIf
Return({size=0,type="none",bank=bank})
EndFunction
Function form_list(_form)
DP("FORM type : ",_form.type, HexStr(_form.size))
DP("Chunks : ",ListItems(_form.chunks))
For Local i=1 To ListItems(_form.chunks)
DP(" ",_form.chunks[i-1].name," : ",(_form.chunks[i-1].size)," @ ", HexStr(_form.chunks[i-1].offset))
Next
EndFunction