I'm afraid my limited supply of computer knowledge is running out. On the other hand, this will be an opportunity to expand it! Very Happy

How do you write an appvar into a binary file?
There's a readme for using convhex here: https://github.com/mateoconlechuga/convhex/blob/master/readme.md

If you have a file you want to turn into an appvar, run:


Code:
convhex -v -n APPVAR -f file.bin appvar.8xv
What file type should file be? Does the .bin mean it's a C file?
It can literally have whatever data you want in it. Text, image data, a tokenized program... It literally just takes whatever bytes are in that file and puts it into an appvar.
I need help with reading text out of an appvar.

I created a text file with "HELLO" in it and ran convhex. It converted it (and created "OmicronC.8xv" as the output file) and I sent it to CEmu along with this program:


Code:
[i]READ

CloseAll
"POINT"->Str0
Open("OmicronC","r")->SLOT
If SLOT=0
   Output(2,1,"Slot does not exist
End
Read(Str0,5,1,SLOT
Output(1,1,Str0
Pause
CloseAll


Whenever I run the program, it outputs "POINT" and the slot error message. How do I fix this problem?
Capitalization may matter, make sure it's right. Or just use all uppercase, that's what I do. It's also possible that you didn't convert the data right using convhex. The syntax looks right to me though (except for the fact that it should be "CloseAll()" instead of "CloseAll"). I would try using the code I posted earlier to write your message into the appvar, then see if your reading code works. If it does, it's an issue with the appvar. I hope this helps, good luck.
Thanks, I'll try that.

Edit: It worked, so I must be using convhex incorrectly. I'll try converting the text file a different way and see if that works.

Edit2: Here's my latest attempt: convhex -v -n APPVAR Clues.txt Omicron.8xv It doesn't work.

Edit3: convhex -v -n OmicronC Clues.txt OmicronC.8xv This one worked, but created a file that CEmu names OMICRONC. How do I tell convhex to keep the text format?
I can't reproduce that. When I use the same command I get the following file in CEmu:



Are you sure you are sending the correct file, and deleted the old one?
I deleted the old file and ran convhex again. This is what the PowerShell looked like:



In the file explorer, the text case is correct, but in CEmu it is still the same.

Are you using the latest convhex release?

https://github.com/mateoconlechuga/convhex/releases/latest
Now that I can read strings out of appvars, I was wondering about reading integers out of appvars.

Since ICE only supports 3-byte integers, I stored "001006" into OmicronC, thinking that the Read( command would eliminate the leading zeros to leave "16". However, none of the programs that I used returned 16.

This is my current one:

Code:
[i]READ
Begin()
CloseAll()
Open("OmicronC","r")->SLOT
If SLOT=0
   PrintString("Slot does not exist
End
Alloc(6->L
Read(L,6,1,SLOT)->READ
If READ=0
   PrintString("Read Error
End
{L}->LENGTH
PrintUInt(LENGTH,2
Pause
CloseAll()
det(1


It returns "3223600" which, I think, is the address of L. I don't know how to fix this.

Can anyone help me?
Did you store bytes, or the string "001006" into the appvar.
Captain Calc wrote:
Now that I can read strings out of appvars, I was wondering about reading integers out of appvars.

Since ICE only supports 3-byte integers, I stored "001006" into OmicronC, thinking that the Read( command would eliminate the leading zeros to leave "16". However, none of the programs that I used returned 16.

This is my current one:

Code:
[i]READ
Begin()
CloseAll()
Open("OmicronC","r")->SLOT
If SLOT=0
   PrintString("Slot does not exist
End
Alloc(6->L
Read(L,6,1,SLOT)->READ
If READ=0
   PrintString("Read Error
End
{L}->LENGTH
PrintUInt(LENGTH,2
Pause
CloseAll()
det(1


It returns "3223600" which, I think, is the address of L. I don't know how to fix this.

Can anyone help me?



Code:

Read(^^oVAR,3,1,SLOT
Write(^^oVAR,3,1,SLOT

3 is however many bytes of the number you want to read/write.
I stored the string "001006" into the appvar.

To beckadam:

Should I write the Read( command like this:

Code:
Read(^^oL,6,1,SLOT)->READ
Captain Calc wrote:
I stored the string "001006" into the appvar.

To beckadam:

Should I write the Read( command like this:

Code:
Read(^^oL,6,1,SLOT)->READ


No, you'll need to write something that converts the text into a number.
You have two options:

Store the BYTES for the number into the appvar, or convert a STRING to a number in ICE.
How would you store the bytes for a number into a appvar? And how would you convert a string into a number?
Use some kind of hex editor, if you are on a crappy OS like windows.

irc wrote:
18:15 <MateoC> https://mh-nexus.de/en/hxd/
18:15 <MateoC> here you go
18:17 <MateoC> https://mh-nexus.de/downloads/HxDPortableSetup.zip
18:17 <MateoC> and there's the link
Thanks. Could you give me an example of how to do it? This is the first time I've used a hex editor.
Well once you open it, you can just start typing bytes in and save it as a file with a .bin extension. Bytes are represented in hexadecimal, if you are unfamiliar with that you can read more about it here: https://simple.wikipedia.org/wiki/Hexadecimal_numeral_system

Essentially the hex editor just shows what bytes are represented in a file. You can try opening the text document you made earlier to see what bytes it consists of. Let us know if you have any other questions! Smile

For instance, if I wanted to write the number '16' to a file to be read by ICE, I would use the following 3 bytes:


Code:
10 00 00
  
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 2 of 4
» 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