Author Topic: How Do I Search the VAT For an Appvar Specified With "input" Without an Axiom?  (Read 4618 times)

0 Members and 1 Guest are viewing this topic.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
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!
I am Bach.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
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.
« Last Edit: January 24, 2014, 03:08:10 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
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:
« Last Edit: January 24, 2014, 03:47:00 pm by Matrefeytontias »

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
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 :)
« Last Edit: January 24, 2014, 02:29:46 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
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.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
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.
« Last Edit: January 24, 2014, 03:10:15 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
Good point. I don't know why I preserved the input's size. Cleanliness I guess.
« Last Edit: January 24, 2014, 02:36:15 pm by Matrefeytontias »

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
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.
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline Matrefeytontias

  • Axe roxxor (kinda)
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1982
  • Rating: +310/-12
  • Axe roxxor
    • View Profile
    • RMV Pixel Engineers
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.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
Documentation says pointer to the "string structure". You're probably right it's an OS variable. Oops :(
* calcdude gets to rewriting
« Last Edit: January 24, 2014, 02:39:10 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.

Offline pimathbrainiac

  • Occasionally I make projects
  • Members
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1731
  • Rating: +136/-23
  • dagaem
    • View Profile
My problem was with using input. I know how to check the VAT with GetCalc() :P

Anyways, thanks!
I am Bach.

Offline calcdude84se

  • Needs Motivation
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2272
  • Rating: +78/-13
  • Wondering where their free time went...
    • View Profile
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
« Last Edit: January 24, 2014, 03:05:32 pm by calcdude84se »
"People think computers will keep them from making mistakes. They're wrong. With computers you make mistakes faster."
-Adam Osborne
Spoiler For "PartesOS links":
I'll put it online when it does something.