There are five reasons that will not work as intended:
- You're using _ChkFindSym (which is for programs, applications, and appvars) instead of _FindSym (which is for everything else)
- You've switched your jumps around, so you're deleting Pic0 if it doesn't exist, and leaving it alone of it does.
- You forgot to actually do the "ldir" at the end of the program.
- If you had, you would break the picture variable, because you forgot to "inc de" twice, skipping the size bytes.
- If you had, you would also corrupt the RAM immediately after the picture variable, since all picture variables are 756 bytes, not 768.
Also, while this technically doesn't break anything, "ld hl, 768" before creating the picture doesn't do anything. Unlike the other variable-creating bcalls, _CreatePict doesn't need to know how large to make the picture, since all picture variables are 756 bytes.
To get the value of Ans, you'll need two bcalls: _RclAns and _ConvOP1. Just call them one after the other. This will get you the value of Ans in A and in DE (use one or the other depending on how large you expect Ans to be).
Then, you'll need to overwrite tPic0, which is the byte at (Pic+2), with the correct token given in A. Unfortunately, Pic0 is a misnomer: it should actually have been "Pic10", because tPic1 = 0, tPic2 = 1, tPic3 = 2, …, tPic9 = 8, and tPic0 = 9. So convert A to the token value you want, and then store it to (Pic+2).
Edit: also, there's an optimization to make.
can be replaced by appropriate use of "rst", which is four bytes smaller and much much faster.