Argus wrote:
Is there a limit to how much data can be written to an Appvar at a time because when I write only 3 characters to it, it works fine. But when I write 34, it doesn't seem to work because reading it out, the string is empty.
Edit: It seems the max is 7 chars at a time? That's what seems to be it.
Final edit: My real question should be, how could I write a string of any length 34 thru 5000 to a new Appvar? So far I've been trying to write the string "00000000000000000000000000000000000000" (38 zeros) to the Appvar STATS and read it out into Str1, but I can't figure out why my code won't work.
Code: "00000000000000000000000000000000000000"→Str1
length(Str1)→L
sum(0
sum(1,"STATS", "w+")→A
sum(4,Str1,L,1,A
sum(1,"STATS","r")→A
sum(5,Str1,38,1,A
det(0
det(18,Str1,3,3
Pause 2000
det(1
To return the string correctly when reading/writing, you must increment the variable L by 1. The string "HELLO" actually contains "HELLO\0" (a null terminator) and that null terminator must be copied as well.
Also, I have not been able to get the 'Read' ( 'sum(5,' ) command working with strings. I have always had to use pointers and then copy the data to a string.
On top of that, ALWAYS make sure to close a slot before reopening it again (you opened slot A twice), and preferably allocate space in a variable before using it with 'Read'
Lastly, you should ALWAYS use single quotes when writing to an AppVar, to avoid ASCII mismatches, string squishing, and the subsequent loss of some or all readable data
Try this (UNTESTED, so preferably in CEmu):
Code: '00000000000000000000000000000000000000'→Str1 // ALWAYS use single quotes when writing to an AppVar
length(Str1)+1→L // Add terminating 0 to length
Alloc(L)→DATA // Allocate L bytes and return a pointer in variable DATA
sum(0
sum(1,"STATS","w+")→A
sum(4,Str1,L,1,A
sum(3,A // Close slot A
sum(1,"STATS","r")→A
sum(5,DATA,L,1,A // Read AppVar into pre-allocated variable DATA
Copy(Str1,DATA,L // Copy all data from DATA into Str1
det(0
det(18,Str1,3,3
Pause 2000
det(1
EDIT: You probably should rename this thread, due to the wide variety of questions you are asking here