Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
DigitalDreams Regular Member Joined: 03/05/2025 Location: United KingdomPosts: 53
Posted: 05:41pm 07 Mar 2026
Copy link to clipboard
Print this post
Having trouble with this command.
If x$="57+93+117"
Val(x$) returns 57 !?
Am I asking too much of val(x$) ?
Martin H. Guru Joined: 04/06/2022 Location: GermanyPosts: 1400
Posted: 05:50pm 07 Mar 2026
Copy link to clipboard
Print this post
yes So it converts the numerical value within a string into a number. But it does not calculate any formulas that are within the string.'no comment
bfwolf Senior Member Joined: 03/01/2025 Location: GermanyPosts: 178
Posted: 05:58pm 07 Mar 2026
Copy link to clipboard
Print this post
Yes, you're asking too much of `VAL(s$)`. This function (as it exists in the BASIC dialect) simply tries to find a number within a string and returns the value after the first match. It doesn't evaluate any expressions!
Try `EVAL(s$)`, which is fortunately available in MMBasic!
Will evaluate 'string$' as if it is a BASIC expression and return the result. 'string$' can be a constant, a variable or a string expression. The expression can use any operators, functions, variables, subroutines, etc that are known at the time of execution. The returned value will be an integer, float or string depending on the result of the evaluation. For example: S$ = "COS(RAD(30)) * 100" : PRINT EVAL(S$) Will display: 86.6025
DigitalDreams Regular Member Joined: 03/05/2025 Location: United KingdomPosts: 53
Posted: 06:25pm 07 Mar 2026
Copy link to clipboard
Print this post
Thanks !, that's the ticket. I'm about to print a truncated version of the latest user manual so none to hand...