a question about VAL function - Sinclair
This is a discussion on a question about VAL function - Sinclair ; Hi all,
could anybody please explain to me why the following piece of BASIC
code:
let a$="sin 1.57" rint val a$
does not work ? All I get is "Nonsence in BASIC" error message. The
same goes for even simpler ...
-
a question about VAL function
Hi all,
could anybody please explain to me why the following piece of BASIC
code:
let a$="sin 1.57"
rint val a$
does not work ? All I get is "Nonsence in BASIC" error message. The
same goes for even simpler stuff, like:
print val"BIN 1011" - the interpreter gives another error message
"Variable not found". Does it mean that the BIN keyword is being
interpreted as an undefined variable? I've come across this problem
only a few days ago, I'm a new user and I simply can not figure this
out.
I've tried to key this in using EmuZWin2.7, and X128 to the same
effect. I haven't tried it yet on a real speccy.
Please help.
regards,
nmbrs
-
Re: a question about VAL function
I hate it when something like rings a bell but the old brain won't cough up
the answer. Was it brackets, was it a bad bit of typing on a 128 that made
it pass syntax. Maybe someone will remind me.
Birian
--
Brian Gaff....Note, this account does not accept Bcc: email.
graphics are great, but the blind can't hear them
Email: briang1@blueyonder.co.uk
__________________________________________________ __________________________________________________ __________
"numbers" wrote in message
news:1372c4e2-3bcf-4a89-8624-d66fc6d75d43@j22g2000hsf.googlegroups.com...
> Hi all,
> could anybody please explain to me why the following piece of BASIC
> code:
> let a$="sin 1.57"
rint val a$
> does not work ? All I get is "Nonsence in BASIC" error message. The
> same goes for even simpler stuff, like:
> print val"BIN 1011" - the interpreter gives another error message
> "Variable not found". Does it mean that the BIN keyword is being
> interpreted as an undefined variable? I've come across this problem
> only a few days ago, I'm a new user and I simply can not figure this
> out.
> I've tried to key this in using EmuZWin2.7, and X128 to the same
> effect. I haven't tried it yet on a real speccy.
> Please help.
>
> regards,
> nmbrs
-
Re: a question about VAL function
It works fine on a 48K system if you insert the actual basic token
into the string. (That's the single byte basic token as opposed to
typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
EXTENDED-B for BIN.
I am unsure if you have been typing it like that.
In any case, I have uploaded this 48K snapshot here which demonstrates
it working (I tested it in EmuZwin 2.7):-
http://www.mediafire.com/?zafgxortaj3
CODE:
10 LET a$="SIN 1.57": PRINT VAL a$
20 LET b$="BIN 1011": PRINT VAL b$
Hope that helps,
DP
-
Re: a question about VAL function
On Aug 25, 8:30 am, Digital Prawn wrote:
> It works fine on a 48K system if you insert the actual basic token
> into the string. (That's the single byte basic token as opposed to
> typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
> EXTENDED-B for BIN.
>
>
>
Looking at Brian Gaff's post, I realise the method I posted is not
applicable to 128K BASIC.
If you are using 128K BASIC, I'm not sure off the top of my head how
to do it.
I just briefly tried it, and got the same error as you did in the 128K
environment.
Hopefully someone may know the answer for 128K BASIC.
-
Re: a question about VAL function
On 25 Sie, 09:47, Digital Prawn wrote:
> On Aug 25, 8:30 am, Digital Prawn wrote:> It works fine on a 48K system if you insert the actual basic token
> > into the string. (That's the single byte basic token as opposed to
> > typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
> > EXTENDED-B for BIN.
>
> Looking at Brian Gaff's post, I realise the method I posted is not
> applicable to 128K BASIC.
>
> If you are using 128K BASIC, I'm not sure off the top of my head how
> to do it.
>
> I just briefly tried it, and got the same error as you did in the 128K
> environment.
>
> Hopefully someone may know the answer for 128K BASIC.
Hi everyone,
you were right, the trick with putting a BASIC keyword token in 48k
environment actually works. Thank you !
But on the other hand - is it possible that 128k BASIC has been
stripped off of such valuable feature like expression evaluation with
VAL? Is there a way around? I can't believe that there is no way of
doing it in BASIC 128.
regards,
nmbrs
-
Re: a question about VAL function
On 25 Sie, 10:26, numbers wrote:
> On 25 Sie, 09:47, Digital Prawn wrote:
>
> > On Aug 25, 8:30 am, Digital Prawn wrote:> It works fine on a 48K system if you insert the actual basic token
> > > into the string. (That's the single byte basic token as opposed to
> > > typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
> > > EXTENDED-B for BIN.
>
> > Looking at Brian Gaff's post, I realise the method I posted is not
> > applicable to 128K BASIC.
>
> > If you are using 128K BASIC, I'm not sure off the top of my head how
> > to do it.
>
> > I just briefly tried it, and got the same error as you did in the 128K
> > environment.
>
> > Hopefully someone may know the answer for 128K BASIC.
>
> Hi everyone,
> you were right, the trick with putting a BASIC keyword token in 48k
> environment actually works. Thank you !
> But on the other hand - is it possible that 128k BASIC has been
> stripped off of such valuable feature like expression evaluation with
> VAL? Is there a way around? I can't believe that there is no way of
> doing it in BASIC 128.
>
> regards,
> nmbrs
Hello again,
I just found out that in fact there is a way of doing it with 128k
BASIC. This is how you can do it:
print val( chr$(196) + "1101" )
chr$(196) stands for BIN keyword.
and it works! But it looks and feels terribly awkward. What if you
want to INPUT a complete math function formula e.g. SIN or COS if
there's no way of using tokens in 128k BASIC? Maybe there is a better
way ?
thank you.
regards,
nmbrs
-
Re: a question about VAL function
This is why I said about the 128k editor. There are newcomers who have never
used the keyword entry.
Brian
--
Brian Gaff - briang1@blueyonder.co.uk
Note:- In order to reduce spam, any email without 'Brian Gaff'
in the display name may be lost.
Blind user, so no pictures please!
"Digital Prawn" wrote in message
news:bd30e75e-b757-4977-abdc-5c92f73dac4c@e39g2000hsf.googlegroups.com...
> It works fine on a 48K system if you insert the actual basic token
> into the string. (That's the single byte basic token as opposed to
> typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
> EXTENDED-B for BIN.
>
> I am unsure if you have been typing it like that.
>
> In any case, I have uploaded this 48K snapshot here which demonstrates
> it working (I tested it in EmuZwin 2.7):-
>
> http://www.mediafire.com/?zafgxortaj3
>
> CODE:
> 10 LET a$="SIN 1.57": PRINT VAL a$
> 20 LET b$="BIN 1011": PRINT VAL b$
>
> Hope that helps,
> DP
>
-
Re: a question about VAL function
Well its only an editor. The trick is to get it to recognise the bin and val
as keyeords and capitalise them in the listing. Its beena while but it can
be done if you space stuff correctly. There are incorrect errors generated
in the 128 editor, its true. I used to know all the dodgies when I was
sighted of course.
I can also recall a poke or two to switch editors, but you had to be
carefull not to generate an error until you were back where you started or
it either crashed or got locked in the editor you were in.
Now if only I could find that file with all this stuff un. I'm sure its on
some web site by now.
Brian
--
Brian Gaff - briang1@blueyonder.co.uk
Note:- In order to reduce spam, any email without 'Brian Gaff'
in the display name may be lost.
Blind user, so no pictures please!
"numbers" wrote in message
news:f9c58cd5-ae61-41a4-9135-f80bdb141eb5@e53g2000hsa.googlegroups.com...
> On 25 Sie, 10:26, numbers wrote:
>> On 25 Sie, 09:47, Digital Prawn wrote:
>>
>> > On Aug 25, 8:30 am, Digital Prawn wrote:>
>> > It works fine on a 48K system if you insert the actual basic token
>> > > into the string. (That's the single byte basic token as opposed to
>> > > typing the function name letter by letter) i.e. EXTENDED-Q for SIN,
>> > > EXTENDED-B for BIN.
>>
>> > Looking at Brian Gaff's post, I realise the method I posted is not
>> > applicable to 128K BASIC.
>>
>> > If you are using 128K BASIC, I'm not sure off the top of my head how
>> > to do it.
>>
>> > I just briefly tried it, and got the same error as you did in the 128K
>> > environment.
>>
>> > Hopefully someone may know the answer for 128K BASIC.
>>
>> Hi everyone,
>> you were right, the trick with putting a BASIC keyword token in 48k
>> environment actually works. Thank you !
>> But on the other hand - is it possible that 128k BASIC has been
>> stripped off of such valuable feature like expression evaluation with
>> VAL? Is there a way around? I can't believe that there is no way of
>> doing it in BASIC 128.
>>
>> regards,
>> nmbrs
>
>
> Hello again,
> I just found out that in fact there is a way of doing it with 128k
> BASIC. This is how you can do it:
>
> print val( chr$(196) + "1101" )
>
> chr$(196) stands for BIN keyword.
> and it works! But it looks and feels terribly awkward. What if you
> want to INPUT a complete math function formula e.g. SIN or COS if
> there's no way of using tokens in 128k BASIC? Maybe there is a better
> way ?
> thank you.
>
> regards,
> nmbrs
-
Re: a question about VAL function
"numbers" wrote:
> you were right, the trick with putting a BASIC keyword token in 48k
> environment actually works. Thank you !
> But on the other hand - is it possible that 128k BASIC has been
> stripped off of such valuable feature like expression evaluation with
> VAL? Is there a way around?
Unfortunately not. And be careful: if you type a keyword in a string in 48
mode, it will work in 128 mode until you edit the line; then the keyword
will turn into a useless string of letters.
Eq.
-
Re: a question about VAL function
numbers wrote:
> Hi all,
> could anybody please explain to me why the following piece of BASIC
> code:
> let a$="sin 1.57"
rint val a$
> does not work ? All I get is "Nonsence in BASIC" error message. The
> same goes for even simpler stuff, like:
> print val"BIN 1011" - the interpreter gives another error message
> "Variable not found". Does it mean that the BIN keyword is being
> interpreted as an undefined variable? I've come across this problem
> only a few days ago, I'm a new user and I simply can not figure this
> out.
The fact that you had sin in lower case tends to lead me to believe you're
actually typing it in letter by letter...
Try that in normal basic, it won't work, will it? (unless you're in 128
mode)
The VAL function works on tokenised basic so you need to use the KEYWORDS
rather than typing them in. I've just experimented in 48k mode to confirm
this. Try
10 LET A$="SIN 1.34" when SIN is extended-mode Q.
20 PRINT VAL A$
--
| spike1@freenet.co,uk | "Are you pondering what I'm pondering Pinky?" |
| Andrew Halliwell BSc | |
| in | "I think so brain, but this time, you control |
| Computer Science | the Encounter suit, and I'll do the voice..." |
-
Re: a question about VAL function
The old manual was very good at explaining tokenised entry. I'm trying to
get to the bottom of whether the original poster was working in 128k basic
or not as I do remember there were some occasions when if you edited a line
written in 48k, it would not re enter in 128k unless some extra space was
added.
Brian
--
Brian Gaff....Note, this account does not accept Bcc: email.
graphics are great, but the blind can't hear them
Email: briang1@blueyonder.co.uk
__________________________________________________ __________________________________________________ __________
"Andrew Halliwell" wrote in message
news:9tjao5-2q6.ln1@ponder.sky.com...
> numbers wrote:
>> Hi all,
>> could anybody please explain to me why the following piece of BASIC
>> code:
>> let a$="sin 1.57"
rint val a$
>> does not work ? All I get is "Nonsence in BASIC" error message. The
>> same goes for even simpler stuff, like:
>> print val"BIN 1011" - the interpreter gives another error message
>> "Variable not found". Does it mean that the BIN keyword is being
>> interpreted as an undefined variable? I've come across this problem
>> only a few days ago, I'm a new user and I simply can not figure this
>> out.
>
> The fact that you had sin in lower case tends to lead me to believe you're
> actually typing it in letter by letter...
>
> Try that in normal basic, it won't work, will it? (unless you're in 128
> mode)
>
> The VAL function works on tokenised basic so you need to use the KEYWORDS
> rather than typing them in. I've just experimented in 48k mode to confirm
> this. Try
> 10 LET A$="SIN 1.34" when SIN is extended-mode Q.
> 20 PRINT VAL A$
>
> --
> | spike1@freenet.co,uk | "Are you pondering what I'm pondering Pinky?"
> |
> | Andrew Halliwell BSc |
> |
> | in | "I think so brain, but this time, you control
> |
> | Computer Science | the Encounter suit, and I'll do the
> voice..." |
-
Re: a question about VAL function
The INSERT mode that I'm working on for open82 solves this particular
problem by allowing you to insert a TOKEN.
For example: Press the GRAPH key (which is now the INSERT key) and
type 255, and you will get the token COPY. It also handles control
codes which is something else that is missing from the UK 128 editor
(although not the Spanish 128 one).
-
Re: a question about VAL function
On 26 Sie, 10:17, "Brian Gaff" wrote:
> The old manual was very good at explaining tokenised entry. I'm trying to
> get to the bottom of whether the original poster was working in 128k basic
> or not as I do remember there were some occasions when if you edited a line
> written in 48k, it would not re enter in 128k unless some extra space was
> added.
>
> Brian
>
Hello,
thanks everyone for your answers it helped me a lot.
I'd like to add that I've experienced that problem while playing with
128k BASIC.
regards,
nmbrs