Omnimaga
Calculator Community => TI Calculators => Axe => Topic started by: Freyaday on March 23, 2011, 04:19:33 pm
-
Something is wrong here, because I seem to be creating the uservars improperly.
Zeros(9)->Z
GetCalc("varC")->A
float{A}->C
...stuff...
GetCalc("varW",18)->A
W->float{A}
This is just the relevant parts, although I am not sure if I left anything out that needs to be here.
-
Something is wrong here, because I seem to be creating the uservars improperly.
Zeros(9)->Z
GetCalc("varC")->A
float{A}->C
...stuff...
GetCalc("varW",18)->A
W->float{A}
This is just the relevant parts, although I am not sure if I left anything out that needs to be here.
W (the Axe variable) doesn't seem to be defined.
-
I think he's thinking that varC defines C and varW defines W.
-
Maybe he was trying to do C->float{A}?
-
No, I edited that part out. To give some context, this is a search engine for an AI I made, and W is one of the variables it returns, and no, it is not C.
-
Something is wrong here, because I seem to be creating the uservars improperly.
Zeros(9)->Z
GetCalc("varC")->A
float{A}->C
...stuff...
GetCalc("varW",18)->A
W->float{A}
This is just the relevant parts, although I am not sure if I left anything out that needs to be here.
I used to have a similar problem, until Quigibo helped me.
First, you don't need to define a real var's size, it's always the same.
Second, when you reference a real var, you need to subtract 2 from the pointer.
So instead of this:
GetCalc("varW",18)->A
W->float{A}
Try this:
GetCalc("varW")->A
W->float{A-2}
I believe this should work.
-
I used to have a similar problem, until Quigibo helped me.
First, you don't need to define a real var's size, it's always the same.
Second, when you reference a real var, you need to subtract 2 from the pointer.
Ah, so even though real vars don't have size bytes, Axe still adds two when returning a value with GetCalc(? That's a bug :-|
-
I thought you had to subtract something. But if don't put the ,18 will Axe still know I'm trying to create the variable instead of find it?
-
Here are the things that seem odd/problematic to me:
- What is Zeros(9)→Z for? It shouldn't cause any problems, but unless you actually use it anywhere, you don't need it.
- Unlike most other variable types, float variables don't have a 2-byte header denoting their size. The GetCalc() routines unfortunately do not account for this, so they exhibit a number of problems when operating on float variables:
- Using GetCalc() to either locate or create a float will expect a size header to be present and thus advance the pointer returned by 2 bytes. However, floats don't have this header and this advance shouldn't be made. This can be corrected for by subtracting 2 from the pointer returned from GetCalc() calls dealing with floats. Make sure to make this adjustment after checking whether or not the function was successful, though, so returned values of 0 indicating failure aren't changed to -2.
- When creating a float, the GetCalc() routine will add an unwanted 2-byte size header. This effect can be negated by decreasing the size argument of the call by 2, so 9-2 for a real variable and 18-2 for a complex variable. I'm guessing you meant to create a real variable with GetCalc("varW",18) and just picked up the 18 from the memory management screen, but you really want 7. Unless you did mean to create a complex variable, in which case you want 16.
Here would be my suggested code for what I have interpreted as what you meant to do:
.Not sure what this line is for.
Zeros(9)→Z
.Don't forget error handling!
!If GetCalc("varC")
.You'll want code here that either jumps to a unified error handler or handles the error itself and returns/quits.
End
.Unless you plan on using the pointer to the OS variable C later, no need to store the GetCalc() result to a variable, you can just carry it right into the float{} command. Also added a -2 to correct for GetCalc() problems.
float{-2}→C
...stuff...
.More error handling! Also changed the size argument to account for GetCalc() issues.
!If GetCalc("varW",9-2)
.More error handling.
End
.Save the pointer to the OS variable because we can't just carry it straight into the float command this time. Also subtracted 2.
-2→A
.Store the Axe value W into the OS value W
W→float{A}
Hopefully this will work. Tell me if you have problems with it.
-
Now I have another problem (different pgrm)
This one is a sprite editor, but I can't get it to make the output string properly.
[303132343536373839414243444546]->GDB1
...muchness of stuff...
GetCalc("Str1",16)->A
For(N,0,1
0->B
For(P,0,15
For(Q,O,3
If pxl-test(P*4+Q^8+87,P*4+Q/8+46+(N*9
e^(3-Q)+B->B
End
End
{GDB1+B}->{A+P}
End
GetCalc("Str2",16)->A
End