Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: Xeda112358 on April 19, 2011, 12:45:01 pm

Title: Create vars in a Parser Hook
Post by: Xeda112358 on April 19, 2011, 12:45:01 pm
I am now trying to get BatLib to create variables like programs and that isn't much of a problem. The problem is that when creating programs or appvars, it throws an error, even if it successfully creates the var! So, I was wondering if there is a special method that I have to go about to create programs and whatnot... ?

Thanks in advance!
Title: Re: Create vars in a Parser Hook
Post by: jnesselr on April 19, 2011, 07:12:05 pm
Can you give your code?
Title: Re: Create vars in a Parser Hook
Post by: thepenguin77 on April 19, 2011, 09:26:06 pm
bcall(_closeEditEqu)

The edit buffer is probably open. If the hook intercepts from the homescreen then you need to close the edit buffer before you can do anything. When you are done, make sure to bcall(_jForceCMDNoChar) or else bad things will happen. Of course you'll have to watch for the cases where the hook is being run from a basic program, then you don't need to do bcall(_closeEditBuffer), and you most certainly don't what to do bcall(_jForceCMDNoChar)
Title: Re: Create vars in a Parser Hook
Post by: Hot_Dog on April 19, 2011, 09:29:40 pm
bcall(_closeEditEqu)

The edit buffer is probably open. If the hook intercepts from the homescreen then you need to close the edit buffer before you can do anything. When you are done, make sure to bcall(_jForceCMDNoChar) or else bad things will happen. Of course you'll have to watch for the cases where the hook is being run from a basic program, then you don't need to do bcall(_closeEditBuffer), and you most certainly don't what to do bcall(_jForceCMDNoChar)

So is this not a consideration for creating strings?  I haven't had this issue when creating temporary strings
Title: Re: Create vars in a Parser Hook
Post by: Xeda112358 on April 19, 2011, 10:39:07 pm
No, I have no issues with creating temporary strings or temp lists or any thing like that. Again, this is for BatLib, so it is during the parser hook that I have this problem and it is only when I create named vars that it has a problem. I have known for some time about this issue, I just haven't gotten around to tackling it :) The same code you would use in a program will not work in a parser hook to create vars, so I was just curious about what I had to do...

An example of code that won't work is:
Code: [Select]
ld hl,3         ;The size of the var to create
bcall(_CreateProg)
You can change the size or the bcall to another similar bcall and it has the same issue.

EDIT: Also, please note that it does make the program, it just throws a syntax error when the parser hook finishes
Title: Re: Create vars in a Parser Hook
Post by: thepenguin77 on April 19, 2011, 11:05:45 pm
The same code you would use in a program will not work in a parser hook to create vars, so I was just curious about what I had to do...


Xeda, throw a bcall(_closeEditEqu) in front of your parser hook code and it will work fine. The problem is that there are 0 bytes of free ram because the home screen edit buffer is open. All of the problems you are having are caused by Err:Memory's.
Title: Re: Create vars in a Parser Hook
Post by: Xeda112358 on April 19, 2011, 11:13:57 pm
It isn't a memory error, it was a syntax error. I just tried it and again, it created the var, but threw a syntax error. That being said, I think I am going to check if I need to adjust the program counter because that might cause a problem.

EDIT: Yeah, that was the problem XD My problem is resolved just by readjusting a few pointers, but thanks much!
EDIT2: Wait, maybe not x.x New error with displaying the program menu after creating the program
EDIT3: So I checked calcsys and it seams that it is really messing with the vat entries, too x.x