If you have any suggestions for improving the manual, this is the place for that. Please reports errors, typos, difficult to understand sections, missing information, etc. Also, any short code segments that better explain a topic are welcome.
Sat Apr 15, 2017 9:29 am
I recently wrote a short function that returns four 8-bit values. But of course a function can only return one value. Easy enough to return as a single 32-bit number with shift and add instructions. Then main program just extracts the values in the opposite way they were packed:
Simple, right? Until I went to print them out with this routine:
PRINT RIGHT$("0"+HEX$(a[v--]),2);" | ";
Which only printed the second and fourth values. This drove me nuts until I read the manual on pre and postfix operators, which referred me to "User Defined Functions", which largely clarified everything. I simply took out the postfix and put a v-=1 before the until. My suggestion is, instead of referring the reader to "User Defined Functions", shouldn't it just tell you in the pre- and postfix section, that they don't work within any
function, not just the user defined? Just a thought.
Mon Apr 17, 2017 12:26 pm
The pre/post fix Ops you used did work.
The problem is with the PRINT command which evaluates functions twice during parsing.
(see "Print with User-Defined Functions" in the manual)
The User-Defined-Functions relationship with function calls you referred to is something different.
When you call a function by reference, it expects a variable. If you pre/post Op it, it becomes a
value (which cannot be passed by reference).
Mon Apr 17, 2017 2:43 pm
You were correct about the print statement, of course. Codewise though, I feel that making an assignment/print out of it ("Z$=RIGHT$(......), followed by PRINT Z$;" |"; is less efficient than just eliminating the postfix. I'm still just the student here, I could be wrong.
Powered by phpBB © phpBB Group.
phpBB Mobile / SEO by Artodia.