### Author Topic: Making appvars  (Read 1812 times)

0 Members and 1 Guest are viewing this topic.

#### Calcman84

• LV0 Newcomer (Next: 5)
• Posts: 1
• Rating: +0/-0
##### Making appvars
« on: May 03, 2011, 03:16:54 pm »
I am getting along with axe, and am making a game, but I need an appvar, how would I make an appvar as a list and a matrix?

#### Fast Crash

• LV4 Regular (Next: 200)
• Posts: 192
• Rating: +45/-7
• Virus of tomorrow
##### Re: Making appvars
« Reply #1 on: May 03, 2011, 03:24:18 pm »
Code: [Select]
"appvNAME"->Str1Getcalc(Str1,SIZE)->P
And then to get each byte(s), use it like :
Code: [Select]
{P} // first byte{P+1} // second byte...{P}r // two first bytes
If you have any other question just ask

#### Michael_Lee

• LV9 Veteran (Next: 1337)
• Posts: 1019
• Rating: +124/-9
##### Re: Making appvars
« Reply #2 on: May 03, 2011, 06:34:41 pm »
Let's say that you want to treat the appvar as a matrix with 5 columns and 4 rows.  For the most part, memory in Axe is treated as a list, not a matrix, so we have to use a workaround to be able to use memory as a matrix.

So, we want a matrix.  Because our matrix has sides of 4 and 5, the total amount of memory we want would be 20 bytes (or 40, if you use double-byte numbers).

We can create an appvar like this:

Code: [Select]
"appvNAME"->Str1GetCalc(Str1,20)->PYou can get the 'appv' symbol by hitting [2ND] then [8].

To write to and access the 5th byte in the appvar, you would do this:
Code: [Select]
42->{P+4}Disp {P+4}>Dec(Remember that lists in computers start at zero: to access the 1st byte, do {P}, which is equal to {P+0}, and to access the last, 20th byte, do {P+19}).

However, if we chose to treat the appvar as a matrix, we can.  The appvar won't be changed in any way, all we're doing is changing the way we access it.
I'm going to arrange the bytes in a block.
Code: [Select]
00  01  02  03  0405  06  07  08  0910  11  12  13  1415  16  17  18  19If we conceptualize the appvar like this, then we can use a short formula-thingy to input the row and column, and return the actual byte we want.

{ROW*LENGTH + COLUMN + POINTER}

So, if we want the byte at column 1, row 2, we would do this:
{2*5+1+P} == {11 + P}
Because this is computers, we treat the first rows/column as the zeroth row/column.

That might be a bit of a complicated answer: let me know if you need anything clarified.
My website: Currently boring.

Projects:
Axe Interpreter
> Core: Done
> Memory: Need write code to add constants.
> Graphics: Rewritten.  Needs to integrate sprites with constants.
> IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
> Stomping bugs
> Internet version: On hold until I can make my website less boring/broken.

#### aeTIos

• Nonbinary computing specialist
• LV12 Extreme Poster (Next: 5000)
• Posts: 3913
• Rating: +184/-32
##### Re: Making appvars
« Reply #3 on: May 05, 2011, 08:50:05 am »
We should add this to the tutorial list, it is very clear I think.
I'm not a nerd but I pretend:

#### Munchor

• LV13 Extreme Addict (Next: 9001)
• Posts: 6199
• Rating: +295/-121
• Code Recycler
##### Re: Making appvars
« Reply #4 on: May 05, 2011, 10:01:40 am »
If this is for high-scores, take a look at this:

Code: [Select]
:"appvNAME"?Str1       ;Give it a name:UnarchiveStr1         ;Unarchive it (no problem if it doesn't exist):GetCalc(Str1)?T       ;Check if it exists:!If T                 ;If it doesn't:GetCalc(Str1,2)       ;Create it (I give it 2 bytes of space):0?{T}^r               ;Let's also set 0 to the first 2 bytes:End
This is me storing 0 to the first two bytes of a bytearray.

Let's say the user beats the highscore, so I do this:
Code: [Select]
500->S                 ;This is the highscoreS?{T}^r                ;Store the highscore in the appvar
I want to display the highscore:

Code: [Select]
Text(0,0,{T}^r>Dec     ;Don't forget the Dec!
« Last Edit: May 05, 2011, 10:02:54 am by Scout »
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.5364790558815002, "perplexity": 16947.17175646063}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-34/segments/1596439738855.80/warc/CC-MAIN-20200811205740-20200811235740-00591.warc.gz"}