user defined functions - Error in BASIC: expected '=' -


i received error "error: expected '='" while trying compile code. i'm guessing has function definition. can help?

1  rem declare function 2  def fns(a) = * 3 4  rem declare variables 5  let numone = 0.0 6  let answer = 0.0 7 8  rem input user 9  input "enter number: "; numone 10 11 rem answer 12 answer = fns(numone) 13 14 rem display answer 15 print "answer: "; fns(numone) 

your code work on many basic variants (e.g. applesoft - see this emulator), not on every one.

if js basic mean this project, realize variant has (as far know) no support def fn, have gosub. also, arguments print , input sepparated simple whitespace (not semi-colon) , mandatory append $ each variable name.

i tweaked code work within constraints (it runs alright in js basic link above). kept line numbers multiplied 10 ease comparison.

00  goto 35 05 10  rem subroutine square 15  rem input: arg$ output: result$ 20  result$ = arg$ * arg$ 25  return 30 35  rem program start 40  rem declare variables 50  numone$ = 0.0 60  answer$ = 0.0 70 80  rem input user 90  input "enter number: " numone$ 100 110 rem answer calling square subroutine 112 arg$ = numone$ 115 gosub 10 120 answer$ = result$ 130 140 rem display answer 150 print "answer: " answer$ 

notice in variant don't have initialize variables before using e.g. input, don't need lines 50 , 60.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -