Keyword list - proofreading requested!

Discussions specifically related to the Android and iOS editions of BBCSDL
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Keyword list - proofreading requested!

Post by Richard Russell »

jeroen_soutberg wrote: Mon 19 Feb 2024, 12:43 I am not sure I see the value of the string version. Or do I miss something?
In BBC BASIC an expression can return a number or a string. An example of an expression which returns a number is '1 + 2' which returns the number '3'. An example of an expression which returns a string is '"one" + "two"' which returns the string '"onetwo"'.

EVAL passes the supplied argument to the 'expression evaluator', hence depending on that argument the expression evaluator may return a number or a string. Here's an example of when EVAL returns a number:

Code: Select all

      expression$ = "1 + 2"
      number = EVAL(expression$)
Here's an example of when EVAL returns a string:

Code: Select all

      expression$ = """one"" + ""two"""
      string$ = EVAL(expression$)
Of course the power of EVAL arises when the expression is somehow 'computed' at run time rather than being a literal string as in these examples, but I hope you can see why both forms are required.