[Gambas-user] File Format Help
John Dovey
dovey.john at gmail.com
Thu Jun 17 18:09:18 CEST 2021
As a followup to my own message, this is what I've gotten to so far. I KNOW
my struct is incorrect, but I'm not sure what it should be. For those
interested, I've included a test.msg file that is maybe a better example.
Public Struct myFidoMsg 'Datatype
fromUserName As Byte[] '36
toUserName As Byte[] '36
subject As Byte[] '72
DateTime As Byte[] ' 20
timesRead As Integer
destNode As Integer
origNode As Integer
cost As Integer
origNet As Integer
destNet As Integer
destZone As Integer
origZone As Integer
destPoint As Integer
origPoint As Integer
replyTo As Integer
Attribute As Integer
nextReply As Integer
text As String 'null terminated
End Struct
Sub Main()
Dim hfile As File
Dim FidoMsg As MyFidoMsg
hfile = Open "test.msg" For Read 'Write Create
FidoMsg = Read #hfile As MyFidoMsg
'Read
'Write #hfile, FidoMsg As MyFidoMsg
Close #hfile
end sub
On Thu, 17 Jun 2021 at 09:46, John Dovey <dovey.john at gmail.com> wrote:
> I hope no-one minds if I ask this here. I'm just really unsure how to do
> this best in Gambas.
> I want to read and write files that have a (very old) specification
> <http://ftsc.org/docs/fts-0001.016>
> Essentially, it looks like this:
>
> 1. Application Layer Data Definition : a Stored Message
>
> Stored Message
>
> Offset
> dec hex
> .-----------------------------------------------.
> 0 0 | |
> ~ fromUserName ~
> | 36 bytes |
> +-----------------------+-----------------------+
> 36 24 | |
> ~ toUserName ~
> | 36 bytes |
> +-----------------------+-----------------------+
> 72 48 | |
> ~ subject ~
> | 72 bytes |
> +-----------------------+-----------------------+
> 144 90 | |
> ~ DateTime ~
> | 20 bytes |
> +-----------------------+-----------------------+
> 164 A4 | timesRead (low order) | timesRead (high order)|
> +-----------------------+-----------------------+
> 166 A6 | destNode (low order) | destNode (high order) |
> +-----------------------+-----------------------+
> 168 A8 | origNode (low order) | origNode (high order) |
> +-----------------------+-----------------------+
> 170 AA | cost (low order) | cost (high order) |
> +-----------------------+-----------------------+
> 172 AC | origNet (low order) | origNet (high order) |
> +-----------------------+-----------------------+
> 174 AE | destNet (low order) | destNet (high order) |
> +-----------------------+-----------------------+
> 176 B0 | destZone (optional) | destZone (optional) |
> +-----------------------+-----------------------+
> 178 B2 | origZone (optional) | origZone (optional) |
> +-----------------------+-----------------------+
> 180 B4 | destPoint(optional) | destPoint(optional) |
> +-----------------------+-----------------------+
> 182 B6 | origPoint(optional) | origPoint(optional) |
> +-----------------------+-----------------------+
> 184 B8 | replyTo (low order) | replyTo (high order) |
> +-----------------------+-----------------------+
> 186 BA | Attribute (low order) | Attribute (high order)|
> +-----------------------+-----------------------+
> 188 BC | nextReply (low order) | nextReply (high order)|
> +-----------------------+-----------------------+
> 190 BE | text |
> ~ unbounded ~
> | null terminated |
> `-----------------------------------------------'
>
> Message = fromUserName(36) (* Null terminated *)
> toUserName(36) (* Null terminated *)
> subject(72) (* see FileList below *)
> DateTime (* message body was last edited *)
> timesRead (* number of times msg has been read *)
> destNode (* of message *)
> origNode (* of message *)
> cost (* in lowest unit of originator's
> currency *)
> origNet (* of message *)
> destNet (* of message *)
> destZone (* of message *)
> origZone (* of message *)
> destPoint (* of message *)
> origPoint (* of message *)
> replyTo (* msg to which this replies *)
> AttributeWord
> nextReply (* msg which replies to this *)
> text(unbounded) (* Null terminated *)
>
> There is a sample packet <https://www.dan.info/sampledata/BAD_BNDL.007> you can look at if you really want to see what it looks like, but this should give you an idea:
>
> [image: image.png]
>
>
> I'm guessing a "Struct" of some sort?
>
> Any advice would be appreciated.
>
>
> John
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210617/293de85e/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 41649 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210617/293de85e/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.msg
Type: application/octet-stream
Size: 523 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210617/293de85e/attachment-0001.obj>
More information about the User
mailing list