I remember that in a old example, you could read you could use fileioc to read and write to a struct.
Let's say I have a struct containing two arrays:

Code:

typedef struct {
    uint16_t idx[202];
    char arr[2021];
} data;


and I write the appvar using the write. How would it look in memory? Would it just be a contingious line of data? Ex:
if idx had something like 1,1,1,1,1,1...
and arr had 'c','c', ....
it would just be 0x0001 0x0001 0x0001 ... 0x63 0x63 ...

Also if I use convbin to convert a csv to appvar, how does it know what size int to use? The -help is rather vague.
I'm not 100% across the toolchain/clibs though the struct fields should be contiguous in a sense (there won't be other data in between them) however I know on some platforms padding can be inserted to align different types to word boundaries for example.

I think for a CSV you would have to convert it to an actual data binary first, then to an appvar. If you convert a CSV then it might be ASCII and may also get the separator? While the converter most likely just creates an array of raw bytes, the size used for the data is really open to interpretation by the user I guess? Someone more familiar with the tool will hopefully be able to help out.
The struct is laid out as 202 2-byte integers, with the least significant byte first and the most significant byte second, followed by 2021 bytes of the char. So, 01 00 01 00 01 00 ... 01 00 63 63 63 63 ...

I believe that convbin uses 8-bit integers. If you want to use other sizes of integers, you could probably use fasmg:

Code:
include 'tiformat.inc'
format ti appvar "MYVAR"

repeat 202
    dw 1
end repeat

repeat 2021
    db 'c'
end repeat


tr1p1ea wrote:
I think for a CSV you would have to convert it to an actual data binary first, then to an appvar. If you convert a CSV then it might be ASCII and may also get the separator? While the converter most likely just creates an array of raw bytes, the size used for the data is really open to interpretation by the user I guess? Someone more familiar with the tool will hopefully be able to help out.

In this case the tool does natively support converting binary data from CSV to other formats - each numeric value is treated as a byte.
I also guess if you need to make a custom util to create a bin from a CSV, then you may as well make it spit out an appvar in a format that you want anyway.

EDIT - After talking to commandz it appears the convbin can take a CSV as a source file! So ignore the above Smile.
Quote:
least significant byte first and the most significant byte second


This is little endian right? or big... sorry I suck as this kind of stuff.
Just confirmed it myself with a little test. Its little endian.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement