Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VAL function #22

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion appendix/basic_commands.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2907,7 +2907,49 @@ \subsection{USR}

\subsection{VAL}

<TODO>
The {\ttfamily VAL} function returns a numeric value representing the characters in a string argument. Often a string
variable is passed to the function, but a literal string is also valid (eg. " -540.15 "). Blank characters ("spaces")
in the string are ignored. If the first non-blank character of the string is not a plus sign (+), minus sign (-),
dollar sign (\$), percentage sign (\%) or a digit the conversion ends with a value of zero (0). These initial special
characters signify the type of number to follow - Positive (+); Negative (-); Hexadecimal (\$), which then validates
the letters A,B,C,D,E \& F; Binary Literal (\%) eg. "010101"; and
Numbers (0123456789). Subsequent valid characters are additional digits (or the first decimal
point or E/e for Exponent). The function ends at the end of the string, or the next non-digit character for that numberic
type and returns the converted result. Subsequent digits after any non-valid characters are disregarded.
Other mathematical terms and arithmetic operations are ignored.\\

The valid range of possible numbers is from -1e+38 to 1e+38. Outside of this range the error "?OVERFLOW ERROR IN <line>"
is shown and the program stops. When the argument isn't a string, the error "?TYPE MISMATCH ERROR IN <line>" would
result and stop the program. When the argument is absent, the error "?SYNTAX ERROR IN <line>" is returned and stops
the program.\\

\codeblock{
10 READ A\$\\
20 DATA " - 120 . 64 "\\
30 PRINT VAL(A\$)\\
RUN\\
-120.64\\
}

Examples:\\

Leading letters are invalid, but don't cause an error.\newline
\codeblock{
PRINT VAL("ABC 123")\\
0\\
}

The binary literal string is converted to decimal number.\newline
\codeblock{
PRINT VAL("\%010101")\\
21\\
}

The exponential notation string is returned as a simplified number.\newline
\codeblock{
PRINT VAL("+352 .25 E-3 Units")\\
0.35225\\
}

\subsection{VPEEK}

Expand Down
Loading