Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: FinaleTI on December 12, 2010, 11:25:22 am

Title: External Vars Tutorial
Post by: FinaleTI on December 12, 2010, 11:25:22 am

1) Appvars and Programs

Appvars and programs have just about the same structure when accessed through Axe. They can have names up to 8 characters in length, that do not start with a number. Appvars can contain lowercase letters in their name, and while programs can, it is more common practice for them to have all uppercase names. This is because if a program contains lowercase letters in its name, it cannot be run from the homescreen.

To access an appvar:

GetCalc("appvAPPVAR")→Pointer

Where 'APPVAR' is to be substituted with the name of the appvar you want to access, and Pointer is where you want the data to point to.
For example:

GetCalc("appvAPPVAR")→A

This stores the location in RAM of the appvar APPVAR to the pointer A. You can then access data in the appvar by using pointers as you normally would.

GetCalc("appvAPPVAR")→A
1→{A}


The code above would store 1 to the first byte of the appvar APPVAR.
The code above will only work if the appvar exists and is in the RAM.

Now, if your appvar doesn't exist, you can easily create it by adding a second argument to your GetCalc() command.

GetCalc("appvAPPVAR",Size)→Pointer

Where Size is the size in bytes of the appvar you want to create.

If the appvar exists, but is in the archive, there are a number of things you can do.
You could unarchive it, but if you are only going to read data from it, this is not the best way to do it.

UnArchive "appvAPPVAR"

Most of the time if you do this, you'll have to end up archiving it when you're done with it.

Archive "appvAPPVAR"

This can take more and more time if you haven't GarbageCollected recently, though. However, this does allow you to save your data in the archive.

If you simply want to read data from an archived appvar, then you could copy it to a file.

GetCalc("appvAPPVAR",File)

Where File is the token for a Y-Var (Y0-Y9).

Once the appvar is copied to a file, you can read from it like a pointer.

GetCalc("appvAPPVAR",Y0)
{Y0}→A


This would store the first byte of your appvar to the pointer A.

Once you no longer need an appvar, you can simply delete it.

DelVar "appvAPPVAR"

This will only work if the appvar is in the RAM. If you copied your appvar to a file, you don't need to worry about deleting a file, as ending the program will take care of clearing the file for you. In addition, you can copy an appvar to a file that you previously used with no adverse effects.

GetCalc("appvAPPVAR",Y0)
GetCalc("appvAPPVAR2",Y0)


This would copy the appvar APPVAR to file Y0, then copy the appvar APPVAR2 to file Y0. Accessing file Y0 would then allow you to access the data in APPVAR2.

Please note that data cannot be stored to files, merely read from files.


Programs can be accessed exactly the same way as appvars, except that you use the 'prgm' token instead of the 'v' you get from [2nd]+[8] (which becomes 'appv' with the Axe Tokens).




2) Real Variables

Accessing real vars is fairly easy to do, actually.
First, getting the pointer to a real var is:

GetCalc("varA")→Pointer

Where A can be substituted with any real var, A-θ, and Pointer is the where you want the data to point to.

Note: If you are using an older version of Axe (pre 0.5.3), then please read the below message. Otherwise, skip it, since it no longer applies, and real vars function like any other external var, pointer-wise.
Now, the tricky part is accessing the data in a real var. Simply doing:

GetCalc("varA")→P
1→float{P}


will not give you proper results. In fact, it will render the variable A invalid until you overwrite it properly, whether inside or outside the Axe program.

The correct offset for accessing a real var is Pointer-2. This is because currently (as of Axe 0.5.2) GetCalc() accounts for the size bytes of a variable, but real vars have no size bytes. Thus, the pointer is offset by 2. This may be fixed in future versions, but until that is stated, stick with Pointer-2 for real vars.

GetCalc("varA")→P
1→float{P-2}

End Note

For Axe 0.5.3 and later, the bug with size bytes always being accounted for no longer exists, so the following is the code you should use:

GetCalc("varA")→P
1→float{P}


This code will store one to the real var A, and you can see that now outside of the Axe program. You can store integers from 0-65535 to real vars using Axe, as Axe only supports two byte numbers. Note: You don't need to put a r after the float command if you are storing a two byte number.
The 'var' token is the 'u' you get from [2nd]+[7] (it becomes 'var' with the Axe tokens).




3) Strings

Strings are actually dealt with in the same way as programs and appvars, storage-wise. The only difference is how you access them.

If you want to use Str0-Str9, you simply use:

GetCalc("StrX")→Pointer

Where StrX is any token from Str0 to Str9. You can also create a string of a certain size by doing:

GetCalc("StrX", Size)→Pointer

Pretty simple, right?




4) Hacked variables

Now here's the fun begins. Say you don't want to touch Str0-Str9, but you need a String for whatever reason. Why not use a hacked variable? For those who don't know what a hacked variable is, the OS only includes the tokens for X amounts of vars, like 10 pictures, or 10 strings. But it actually supports up to 255 different pictures, strings, or whatever other var! These don't have tokens like Str99, so they will show up as a seemingly random token, that may look exactly like another token, but they serve a very different function. These hacked tokens function exactly the same as the normal ones. In Hybrid BASIC games, using hacked pictures is actually a fairly common procedure, since it allows for more graphics easily.

In order to use a hacked variable, it's not as straight forward as a normal one, but it's not really that difficult either. Just different.

For the purposes of this lesson, we'll be using Str1 as a static pointer for our hacked names, but you can just as easily place the data in the GetCalc() statement.

For example, the lesson will present the data like this:
[015D]"M"→Str1
GetCalc(Str1)→P


But you can just as easily do this:
GetCalc([015D]"M")→P
and it should still work correctly.

I've broken down the next section based on what type of var you're looking to use, so find it and read the section.

Hacked Pictures

So you wanna use a hacked picture? That's simple enough.
[0760]Data(#,0)→Str1
# here represents the number of the picture you want to use. Keep in mind that 0 is Pic1, 1 is Pic2, etc., with 10 being Pic0. 11 and up are the hacked pics, and they will use odd tokens to represent themselves in the memory menu.
Once you have your name, getting a pointer is as simple as:
GetCalc(Str1)→Pointer

And creating the picture is as simple as:
GetCalc(Str1, Size)→Pointer


Hacked Strings

Coming soon...






5) Accessing Arbitrary Variables (courtesy of squidgetx)

Copy("HI",L1+1,2)
0->{L1+3}
E15->{L1}
GetCalc(L1)->A

It does the same thing as GetCalc("appvHI")->A, but I'm sure you can think of many applications of this method instead (shells and mem readers come to mind). You can use 05 to get a program or 06 to get a protected program (instead of $15). Other prefixes you may be able to use are (taken from the SDK. also I haven't tested all of these and would be wary if you tried GetCalc'ing an application for example)
Data Types:
00h Real
01h List
02h Matrix
03h Equation
04h String
05h Program
06h Protected Program
07h Picture
08h Graph Database
0Bh New EQU  
0Ch Complex
0Dh Complex
14h Application
15h AppVar
17h Group

This could be taken as a little confusing, so let's break this down a little bit.


Copy("HI",L1+1,2)
This line copies the name of the variable (in this case, "HI") to L1+1.

0->{L1+3}
This line adds the null byte or terminating zero to the end of the name string starting at L1+1. Where 3 is would be the length of the variable name + 1.

E15->{L1}
This line stores the type byte of the variable to L1. In this case, it's denotating an appvar. The E means the number that follows is the hexadecimal equivalent, so any of the hex numbers from the above list would work here in place of the 15.

GetCalc(L1)->A
This uses the string you just constructed at the beginning of L1 to create the variable.


Title: Re: External Vars Tutorial
Post by: Deep Toaster on December 12, 2010, 11:36:36 am
Nice, it seems pretty clear so far, but I think it just goes a bit fast between topics.

And this is probably my problem, but there are weird chars appearing between lines ???
Title: Re: External Vars Tutorial
Post by: Michael_Lee on December 12, 2010, 11:58:04 am
Yeah, I opened it with notepad, and I'm seeing a lot of Chinese characters appearing.

Is there a specific way we're supposed to view the text document?
Title: Re: External Vars Tutorial
Post by: FinaleTI on December 12, 2010, 12:01:25 pm
Does it show up properly now?

1) Appvars and Programs
Spoiler For Spoiler:
Appvars and programs have just about the same structure when accessed through Axe. They can have names up to 8 characters in length, that do not start with a number. Appvars can contain lowercase letters in their name, and while programs can, it is more common practice for them to have all uppercase names. This is because if a program contains lowercase letters in its name, it cannot be run from the homescreen.

To access an appvar:
Code: [Select]
GetCalc("appvAPPVAR")→PointerWhere 'APPVAR' is to be substituted with the name of the appvar you want to access, and Pointer is where you want the data to point to.
For example:
Code: [Select]
GetCalc("appvAPPVAR")→AThis stores the location in RAM of the appvar APPVAR to the pointer A. You can then access data in the appvar by using pointers as you normally would.
Code: [Select]
GetCalc("appvAPPVAR")→A
1→{A}
The code above would store 1 to the first byte of the appvar APPVAR.
The code above will only work if the appvar exists and is in the RAM.

Now, if your appvar doesn't exist, you can easily create it by adding a second argument to your GetCalc() command.
Code: [Select]
GetCalc("appvAPPVAR",Size)→PointerWhere Size is the size in bytes of the appvar you want to create.

If the appvar exists, but is in the archive, there are a number of things you can do.
You could unarchive it, but if you are only going to read data from it, this is not the best way to do it.
Code: [Select]
UnArchive "appvAPPVAR"Most of the time if you do this, you'll have to end up archiving it when you're done with it.
Code: [Select]
Archive "appvAPPVAR"This can take more and more time if you haven't GarbageCollected recently, though. However, this does allow you to save your data in the archive.

If you simply want to read data from an appvar, then you could copy it to a file.
Code: [Select]
GetCalc("appvAPPVAR",File)Where File is the token for a Y-Var (Y0-Y9).
as of Axe 0.4.6 using files is a little limited, but they are supposed to become more flexible in future versions.
Once the appvar is copied to a file, you can read from it like a pointer.
Code: [Select]
GetCalc("appvAPPVAR",Y0)
{Y0}→A
This would store the first byte of your appvar to the pointer A.

Once you no longer need an appvar, you can simply delete it.
Code: [Select]
DelVar "appvAPPVAR"This will only work if the appvar is in the RAM. If you copied your appvar to a file, you don't need to worry about deleting a file, as ending the program will take care of clearing the file for you. In addition, you can copy an appvar to a file that you previously used with no adverse effects.
Code: [Select]
GetCalc("appvAPPVAR",Y0)
GetCalc("appvAPPVAR2",Y0)
This would copy the appvar APPVAR to file Y0, then copy the appvar APPVAR2 to file Y0. Accessing file Y0 would then allow you to access the data in APPVAR2.

Please note that data cannot be stored to files, merely read from files.


Programs can be accessed exactly the same way as appvars, except that you use the 'prgm' token instead of the 'v' you get from [2nd]+[8] (which becomes 'appv' with the Axe Tokens).

2) Real Variables
Spoiler For Spoiler:
Accessing real vars is fairly easy to do, actually.
First, getting the pointer to a real var is:
Code: [Select]
GetCalc("varA")→PointerWhere A can be substituted with any real var, A-θ, and Pointer is the where you want the data to point to.

Now, the tricky part is accessing the data in a real var. Simply doing:
Code: [Select]
GetCalc("varA")→P
1→float{P}
will not give you proper results. In fact, it will render the variable A invalid until you overwrite it properly, whether inside or outside the Axe program.

The correct offset for accessing a real var is Pointer-2.
Code: [Select]
GetCalc("varA")→P
1→float{P-2}
This code will store one to the real var A, and you can see that now outside of the Axe program. You can store 0-65535 to real vars using Axe, as Axe only supports two byte numbers. Note: You don't need to put a r after the float command if you are storing a two byte number.
The 'var' token is the 'u' you get from [2nd]+[7] (it becomes 'var' with the Axe tokens).
Title: Re: External Vars Tutorial
Post by: Michael_Lee on December 12, 2010, 12:04:56 pm
Yup.  It shows up perfectly now.
Title: Re: External Vars Tutorial
Post by: Deep Toaster on December 12, 2010, 12:05:17 pm
Yep, now it does, just not in the .txt.

Not sure, but I think it adds weird chars in if you copy-paste it from the Print Topic page.
Title: Re: External Vars Tutorial
Post by: souvik1997 on December 12, 2010, 01:23:05 pm
Can you create programs and change their sizes later?
Title: Re: External Vars Tutorial
Post by: Deep Toaster on December 12, 2010, 01:28:51 pm
There's are InsertMem/DeleteMem b_calls to do just that. You have to check for yourself if there's enough free RAM, though, and you also have to update the size bytes (the two-byte number stored just before the program data).
Title: Re: External Vars Tutorial
Post by: Calcaholic on February 04, 2011, 05:39:02 am
I've got troubles with the length( function used on appvars.

For example, with the following code I get the output 14, allthoug it should be 5, I guess...

Code: [Select]
GetCalc("appvTST",5)->P
length({P})->B
Disp B>Dec

I have experimented with this function some time now and always got very confusing results...
Title: Re: External Vars Tutorial
Post by: squidgetx on February 04, 2011, 07:18:08 am
When you create an appvar, it isn't always filled with zeros. Also, you don't need the curly brackets; length(P) will do.
Title: Re: External Vars Tutorial
Post by: Deep Toaster on February 04, 2011, 09:11:15 am
When you create an appvar, it isn't always filled with zeros. Also, you don't need the curly brackets; length(P) will do.

Yep, in fact length({P}) does something different from what you want.
Title: Re: External Vars Tutorial
Post by: Calcaholic on February 04, 2011, 11:06:12 am
I tried it without those brackets too, but in this case I always got the output 0...

And by the way, I used the ZEROS( function to fill the appvar, but left line this out in the example, because I thought it wouldn't matter for the size length.
Title: Re: External Vars Tutorial
Post by: ACagliano on February 04, 2011, 11:24:12 am
The zeros function just adds zeros to the end of the program when Axe compiles. It has no effect on the actual executable.

Also, you must do

"appvTST"->Str0
GetCalc(Str0,5)->P
length(P)->B
Disp B>Dec
Title: Re: External Vars Tutorial
Post by: squidgetx on February 04, 2011, 11:42:30 am
@Acagliano; Quigibo added support for inline data, so putting the string into the getcalc command is fine.

Calcaholic; the reason it would return 0 is because the length function does its work using 0 to signify the "end" byte of the data string. So if your appvar contained the values 1,2,3,4,5,0,7,8,9,10 then length() would return 5. Since you filled it with zeros beforehand, that's why it is giving a length of 0
Title: Re: External Vars Tutorial
Post by: kindermoumoute on February 04, 2011, 12:40:00 pm
3)... ?
good job. ;)
Title: Re: External Vars Tutorial
Post by: Calcaholic on February 06, 2011, 01:10:44 pm
Thank you all; Now it's all as it should be... :)
Title: Re: External Vars Tutorial
Post by: Builderboy on February 06, 2011, 01:14:39 pm
The length of appvars and programs is stored in the 2 bytes before the pointer, so using {P-2}r would give you the length :)
Title: Re: External Vars Tutorial
Post by: Calcaholic on February 06, 2011, 01:40:06 pm
ok, that works either. :)
Title: Re: External Vars Tutorial
Post by: DJ Omnimaga on February 07, 2011, 02:05:22 pm
I'll need to check that tutorial eventually. Getcalc function is what pretty much lead to me quitting Axe development. I never could stop being confused between both syntaxes (which is why I think there should be one command to create the appvar and a different one to read from an appvar...). Hopefully this should be useful to other people too, since a lot of the help topics being posted are about appvars.
Title: Re: External Vars Tutorial
Post by: Builderboy on February 07, 2011, 06:44:31 pm
which is why I think there should be one command to create the appvar and a different one to read from an appvar...

Wait, i'm confused, isn't there only one command to create them and only one command to read from them? getCalc() can create them, and using a pointer can read from them?
Title: Re: External Vars Tutorial
Post by: FinaleTI on February 07, 2011, 06:49:38 pm
I should probably start working on this again after the Cage Match...
Title: Re: External Vars Tutorial
Post by: squidgetx on February 12, 2011, 04:01:19 pm
Yeah, you should ;D

Maybe more discussion on file pointers, as well as other variable types. Also discussion on how to access an arbitrary variable (without a name string) would be nice.
Spoiler For Spoiler:
Basically, you can use free ram as your 'name string' For example, the following code is totally valid:
Copy("HI",L1+1,2)
0->{L1+3}
E15->{L1}
GetCalc(L1)->A

It does the same thing as GetCalc("appvHI")->A, but I'm sure you can think of many applications of this method instead (shells and mem readers come to mind). You can use 05 to get a program or 06 to get a protected program (instead of $15). Other prefixes you may be able to use are (taken from the SDK. also I haven't tested all of these and would be wary if you tried GetCalc'ing an application for example)
00h Real
01h List
02h Matrix
03h Equation
04h String
05h Program
06h Protected Program
07h Picture
08h Graph Database
0Bh New EQU 
0Ch Complex
0Dh Complex
14h Application
15h AppVar
17h Group
Title: Re: External Vars Tutorial
Post by: DJ Omnimaga on February 12, 2011, 07:35:25 pm
which is why I think there should be one command to create the appvar and a different one to read from an appvar...

Wait, i'm confused, isn't there only one command to create them and only one command to read from them? getCalc() can create them, and using a pointer can read from them?
Indeed, but I feel it would be better if something else than getCalc was used to create them. Otherwise we always get confused between both syntaxes (the main reason why so many people have troubles understanding appvars)
Title: Re: External Vars Tutorial
Post by: FinaleTI on February 20, 2011, 03:01:48 pm
Slight update, and new section thanks to what squidgetx posted.

1) Appvars and Programs
Spoiler For Spoiler:
Appvars and programs have just about the same structure when accessed through Axe. They can have names up to 8 characters in length, that do not start with a number. Appvars can contain lowercase letters in their name, and while programs can, it is more common practice for them to have all uppercase names. This is because if a program contains lowercase letters in its name, it cannot be run from the homescreen.

To access an appvar:
Code: [Select]
GetCalc("appvAPPVAR")→PointerWhere 'APPVAR' is to be substituted with the name of the appvar you want to access, and Pointer is where you want the data to point to.
For example:
Code: [Select]
GetCalc("appvAPPVAR")→AThis stores the location in RAM of the appvar APPVAR to the pointer A. You can then access data in the appvar by using pointers as you normally would.
Code: [Select]
GetCalc("appvAPPVAR")→A
1→{A}
The code above would store 1 to the first byte of the appvar APPVAR.
The code above will only work if the appvar exists and is in the RAM.

Now, if your appvar doesn't exist, you can easily create it by adding a second argument to your GetCalc() command.
Code: [Select]
GetCalc("appvAPPVAR",Size)→PointerWhere Size is the size in bytes of the appvar you want to create.

If the appvar exists, but is in the archive, there are a number of things you can do.
You could unarchive it, but if you are only going to read data from it, this is not the best way to do it.
Code: [Select]
UnArchive "appvAPPVAR"Most of the time if you do this, you'll have to end up archiving it when you're done with it.
Code: [Select]
Archive "appvAPPVAR"This can take more and more time if you haven't GarbageCollected recently, though. However, this does allow you to save your data in the archive.

If you simply want to read data from an archived appvar, then you could copy it to a file.
Code: [Select]
GetCalc("appvAPPVAR",File)Where File is the token for a Y-Var (Y0-Y9).

Once the appvar is copied to a file, you can read from it like a pointer.
Code: [Select]
GetCalc("appvAPPVAR",Y0)
{Y0}→A
This would store the first byte of your appvar to the pointer A.

Once you no longer need an appvar, you can simply delete it.
Code: [Select]
DelVar "appvAPPVAR"This will only work if the appvar is in the RAM. If you copied your appvar to a file, you don't need to worry about deleting a file, as ending the program will take care of clearing the file for you. In addition, you can copy an appvar to a file that you previously used with no adverse effects.
Code: [Select]
GetCalc("appvAPPVAR",Y0)
GetCalc("appvAPPVAR2",Y0)
This would copy the appvar APPVAR to file Y0, then copy the appvar APPVAR2 to file Y0. Accessing file Y0 would then allow you to access the data in APPVAR2.

Please note that data cannot be stored to files, merely read from files.


Programs can be accessed exactly the same way as appvars, except that you use the 'prgm' token instead of the 'v' you get from [2nd]+[8] (which becomes 'appv' with the Axe Tokens).

2) Real Variables
Spoiler For Spoiler:
Accessing real vars is fairly easy to do, actually.
First, getting the pointer to a real var is:
Code: [Select]
GetCalc("varA")→PointerWhere A can be substituted with any real var, A-θ, and Pointer is the where you want the data to point to.

Now, the tricky part is accessing the data in a real var. Simply doing:
Code: [Select]
GetCalc("varA")→P
1→float{P}
will not give you proper results. In fact, it will render the variable A invalid until you overwrite it properly, whether inside or outside the Axe program.

The correct offset for accessing a real var is Pointer-2.
Code: [Select]
GetCalc("varA")→P
1→float{P-2}
This code will store one to the real var A, and you can see that now outside of the Axe program. You can store 0-65535 to real vars using Axe, as Axe only supports two byte numbers. Note: You don't need to put a r after the float command if you are storing a two byte number.
The 'var' token is the 'u' you get from [2nd]+[7] (it becomes 'var' with the Axe tokens).

3) Accessing Arbitrary Variables (courtesy of squidgetx)
Spoiler For Spoiler:
Copy("HI",L1+1,2)
0->{L1+3}
E15->{L1}
GetCalc(L1)->A

It does the same thing as GetCalc("appvHI")->A, but I'm sure you can think of many applications of this method instead (shells and mem readers come to mind). You can use 05 to get a program or 06 to get a protected program (instead of $15). Other prefixes you may be able to use are (taken from the SDK. also I haven't tested all of these and would be wary if you tried GetCalc'ing an application for example)
Data Types:
00h Real
01h List
02h Matrix
03h Equation
04h String
05h Program
06h Protected Program
07h Picture
08h Graph Database
0Bh New EQU 
0Ch Complex
0Dh Complex
14h Application
15h AppVar
17h Group

This could be taken as a little confusing, so let's break this down a little bit.


Copy("HI",L1+1,2)
This line copies the name of the variable (in this case, "HI") to L1+1.

0->{L1+3}
This line adds the null byte or terminating zero to the end of the name string starting at L1+1. Where 3 is would be the length of the variable name + 1.

E15->{L1}
This line stores the type byte of the variable to L1. In this case, it's denotating an appvar. The E means the number that follows is the hexadecimal equivalent, so any of the hex numbers from the above list would work here in place of the 15.

GetCalc(L1)->A
This uses the string you just constructed at the beginning of L1 to create the variable.
Title: Re: External Vars Tutorial
Post by: Elsewhere on February 20, 2011, 11:05:05 pm
So, should this work or is there something I missed?
Code: [Select]
:!If GetCalc("appvPOLSC")
:GetCalc("appvPOLSC",37)->N
:For(A,0,37)
:0->{N+A}
:End
:End
:GetCalc("appvPOLSC")->N
:For(A,0,37)
:!If {N+A}
:.(do something)
:Else
:.(do something else)
:End
:End
What it should do is either load from an existing appvar or create the appvar, and then store it to N for reading. All it does is fail to create the appvar (and I've made sure there was enough RAM, as well as tested on Wabbit). After running the program, the calculator will load the PRGM menu really slowly and will eventually crash on something. Anyway, I've been staring blankly at these lines of code for too long. Any insight would be appreciated. :P
Title: Re: External Vars Tutorial
Post by: Deep Toaster on February 20, 2011, 11:07:34 pm
For(A,0,36). If it's For(A,0,37) you're storing 38 bytes of memory, the last of which probably messes up the size byte of one of the programs (which would be really really bad :P).
Title: Re: External Vars Tutorial
Post by: Elsewhere on February 20, 2011, 11:49:40 pm
Hm, nothing seemed to change. ???
Is there something else I did wrong?
Title: Re: External Vars Tutorial
Post by: Deep Toaster on February 21, 2011, 12:29:33 am
Did you change both the For( statements?
Title: Re: External Vars Tutorial
Post by: Elsewhere on February 21, 2011, 12:40:36 am
Yeah, and then when it didn't work I added ample length to the created appvar and it still didn't work.
Title: Re: External Vars Tutorial
Post by: FinaleTI on February 21, 2011, 04:33:06 pm
When you typed the "appv" in the name, did you type "appv" with lowercase letters or did you use the appv symbol Axe gives you when you press 2nd and 8?
You need to use the 2nd and 8 key combo to get the appv token (it's a lowercase v symbol normally) to properly reference an appvar.
Title: Re: External Vars Tutorial
Post by: Elsewhere on February 21, 2011, 04:42:56 pm
Ah, thanks!

I initially did, but then I put it on pastebin and that messed it up (gave me "appv" in small letters). So, there's a problem solved!
Title: Re: External Vars Tutorial
Post by: DJ Omnimaga on June 14, 2011, 03:36:14 pm
Update: Got rid of spoilers so this shows up properly in the tutorials section.
Title: Re: External Vars Tutorial
Post by: Hayleia on July 17, 2011, 08:25:40 am
If you simply want to read data from an archived appvar, then you could copy it to a file.

GetCalc("appvAPPVAR",File)

Where File is the token for a Y-Var (Y0-Y9).

Once the appvar is copied to a file, you can read from it like a pointer.

GetCalc("appvAPPVAR",Y0)
{Y0}→A


This would store the first byte of your appvar to the pointer A.

Only two three questions for me ;D
Does the copying work if the appvar is huge (like 10325 bytes) ?
Is the file automatically removed at the end of the program ?
How many RAM of files do we dispose of (if I want a lot of huge files) ?
Title: Re: External Vars Tutorial
Post by: FinaleTI on July 17, 2011, 11:34:45 am
Copying will work for virtually any size, you just need to make sure that you have enough RAM for the destination you're copying to.

Files, if I'm not mistaken, are pointers to variables in flash, so you have no need to worry about removing them.

Files shouldn't affect your RAM unless you need to copy something from them to RAM. I believe the size limit for a file is somewhere around 39000 bytes, but I could be wrong.
Title: Re: External Vars Tutorial
Post by: Hayleia on July 17, 2011, 01:42:52 pm
Ok, thank you :)
By the way, this is a great tutorial :thumbsup:
Title: Re: External Vars Tutorial
Post by: FinaleTI on July 17, 2011, 02:17:35 pm
Thanks.

I just added a bit more. The tutorial now also touches on accessing strings, and I began a section on utilizing hacked variables.
Title: Re: External Vars Tutorial
Post by: Ft.lou on June 20, 2013, 08:44:11 am
nice!
It's clear now :-)