Help with Function in BBC Basic Android

Discussions about the BBC BASIC language, with particular reference to BB4W and BBCSDL
User avatar
zachnoland
Posts: 11
Joined: Sat 07 Dec 2024, 15:22
Location: somewhere in Southeast Asia

Help with Function in BBC Basic Android

Post by zachnoland »

I tried the function in BASIC but the result I got was the error "No such variable", I don't know where I went wrong I have followed the tutorial on BBCMUG. this is my code:

Code: Select all

   10 DEF LOLSUM(X, Y)
   20 X = X + Y
   30 RETURN X
   40 ENDPROC
   50 PRINT "FUNCTION TEST"
   60 A = 5
   70 B = 5
   80 PRINT "RESULT: "; LOLSUM(A,B)
   90 END
Hi everyone! My name Zach Noland. I am a Game Developer, My main programming language is C/C++. I am interested in Basic Programming Language, Previously I had tried BlitzBasic, That's amazing!
Nice to meet you :D
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Help with Function in BBC Basic Android

Post by Richard Russell »

zachnoland wrote: Sat 07 Dec 2024, 15:30 I tried the function in BASIC but the result I got was the error "No such variable", I don't know where I went wrong
That doesn't look anything like BBC BASIC code, it's more similar to Microsoft BASIC or one of the others which are based on it.
I have followed the tutorial on BBCMUG. this is my code:
I'm not familiar with that. The BBC BASIC tutorial is here.

Re-writing your program in BBC BASIC it would look something like this:

Code: Select all

   10 PRINT "FUNCTION TEST"
   20 A = 5
   30 B = 5
   40 PRINT "RESULT: "; FNLOLSUM(A,B)
   50 END
   60 DEF FNLOLSUM(X, Y)
   70 X = X + Y
   80 = X
User avatar
zachnoland
Posts: 11
Joined: Sat 07 Dec 2024, 15:22
Location: somewhere in Southeast Asia

Re: Help with Function in BBC Basic Android

Post by zachnoland »

Thank you very much :D
Last edited by zachnoland on Sun 08 Dec 2024, 01:20, edited 1 time in total.
User avatar
zachnoland
Posts: 11
Joined: Sat 07 Dec 2024, 15:22
Location: somewhere in Southeast Asia

Re: Help with Function in BBC Basic Android

Post by zachnoland »

Richard Russell wrote: Sat 07 Dec 2024, 16:07

Code: Select all

10 PRINT "FUNCTION TEST"
20 A = 5
30 B = 5
40 PRINT "RESULT: "; FNLOLSUM(A,B)
50 END
60 DEF FNLOLSUM(X, Y)
70 X = X + Y
80 = X
Thank you very much :D
I thought that functions in BBC BASIC were written as DEF only, but it turns out that DEF and FN are needed.I think I misunderstood what was written in the BBCMUG book.
I'm not familiar with that. The BBC BASIC tutorial is here.
Btw BBCMUG is an abbreviation of (BBC Microcomputer System User Guide) the book was written by John Coll in 1984
Richard Russell
Posts: 272
Joined: Tue 18 Jun 2024, 09:32

Re: Help with Function in BBC Basic Android

Post by Richard Russell »

zachnoland wrote: Sun 08 Dec 2024, 01:00 Btw BBCMUG is an abbreviation of (BBC Microcomputer System User Guide)
Ah, I've not seen that abbreviation for it used before. BBC BASIC has come a long way since then (everything documented about BASIC in that User Guide should still be valid, but there's a lot more now, mostly added with BBC BASIC V in 1986 or thereabouts).