Omnimaga

Calculator Community => TI Calculators => Axe => Topic started by: pimathbrainiac on January 24, 2014, 01:26:15 pm

Title: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: pimathbrainiac on January 24, 2014, 01:26:15 pm
How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?

I need a routine that will do this for the map editor for VVVVVV.

Example:

asm(prgmVVVVVCME)
[User types appvar name without the "appv"]

if it exists -> go to map editor
else -> specify size, then go to map editor

Thanks for the help in advance!
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calcdude84se on January 24, 2014, 02:17:56 pm
I'm assuming you might want to read from Archive. If so, this code should work: (Note: requires 9 bytes of RAM, here assumed to be at L1)
Code: [Select]
21->{L1} .The 21 means appvar
Copy(input,L1+1,8)
If GetCalc(L1,Y1)
.Variable exists, Y1 is the relevant file
Else
.Variable doesn't exist
End
I'm gonna test this, but it ought to be good.
Edit: For posterity: this code is wrong, mainly because I forgot how input works. It often gets the right result, but it's a coincidence that it does.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: Matrefeytontias on January 24, 2014, 02:19:36 pm
Why not just using GetCalc ?

:[15]->Str1
:Buff(8 )
:
:Fill(Str1+1, 8, 0)
:Copy(input->A, Str1+1, min({A-2}r, 8 ))
:!If GetCalc(Str1)
:.Specify size in S for example
:Return!If GetCalc(Str1,S)->M
:Else
:->M
:End


EDIT : :ninja:
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calcdude84se on January 24, 2014, 02:24:01 pm
Right, and you can also do it by modifying some data in the program. (Note that only needs to Buff(8 ), though, and there's no need to pre-fill it with zeros)
Edit: Tested and works :)
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: Matrefeytontias on January 24, 2014, 02:28:31 pm
There is, if you want to have input multiple times during the program. In this case, if you input ABCDEF and then ACDE, Str1 will contain ACDEEF if you don't fill it with zeros before each input.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calcdude84se on January 24, 2014, 02:34:33 pm
Nope. The string pointed to by input is null-terminated, which is copied over (unless it's 8 chars, but that's okay) and that's how GetCalc( reads it as well. And if the name is 8 characters long, it doesn't need a null.
Edit: Tested it like this; it worked:
Code: [Select]
21->{L1
Fill(L1+1,9,85 .Garbage
For(X,1,2
Copy(input,L1+1,8
If GetCalc(L1,Y1
Disp "HURRAY
Else
Disp "AWW...
End
End
The names, in order, were ASAVEPIC and DCS7.
Edit: For posterity: this code is wrong, mainly because I forgot how input works. It often gets the right result, but it's a coincidence that it does.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: Matrefeytontias on January 24, 2014, 02:36:02 pm
Good point. I don't know why I preserved the input's size. Cleanliness I guess.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calc84maniac on January 24, 2014, 02:36:23 pm
Nope. The string pointed to by input is null-terminated, which is copied over (unless it's 8 chars, but that's okay) and that's how GetCalc( reads it as well. And if the name is 8 characters long, it doesn't need a null.
Actually, doesn't input return a pointer to the data section of a temporary variable? It's preceded by a two-byte length, and likely not zero-terminated.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: Matrefeytontias on January 24, 2014, 02:37:46 pm
Apparently it is null-terminated, since he says he tested and it worked. I never tried without filling Str1 with zeros, so I can only say that my method works.
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calcdude84se on January 24, 2014, 02:38:27 pm
Documentation says pointer to the "string structure". You're probably right it's an OS variable. Oops :(
/me gets to rewriting
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: pimathbrainiac on January 24, 2014, 02:39:13 pm
My problem was with using input. I know how to check the VAT with GetCalc() :P

Anyways, thanks!
Title: Re: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?
Post by: calcdude84se on January 24, 2014, 02:55:19 pm
All right, fixed code time. Now requires 10 bytes of RAM at L1 'cause I don't feel like special-casing the length-8 case.
Code: [Select]
21->{L1}
Copy(input->P,L1+1,min({P-2}r,8))
Asm(EB3600) .Puts 0 at the end. Assumes DE=Y+L after Copy(X,Y,L). Else just do 0->{L1+1+L}, where L is stored from the call to min(
If GetCalc(L1,Y1
.Exists
Else
.DNE
End
Edit: Works, and for the right reasons this time. :D