Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 09:05 01 Aug 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Call Subroutine with Missing Parameter - Bug?

Author Message
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 04:07am 22 Jun 2022
Copy link to clipboard 
Print this post

Strange behaviour on my CMM2 (v5.0702)

The manual says "missing values will be assumed to be either zero or an empty string."
> list
option default integer
i = 0
testsub
testsub 1
testsub:testsub 2
testsub :testsub 3
print "Number of calls:" i
end

sub testsub n
  print "parameter =" n
  i = i + 1
end sub

> run
parameter = 0
parameter = 1
parameter = 2
parameter = 0
parameter = 3
Number of calls: 5

Note the missing result before the call with the parameter set to 2. If a colon appears immediately after the subroutine name, the subroutine doesn't appear to be called at all.
Visit Vegipete's *Mite Library for cool programs.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6283
Posted: 04:22am 22 Jun 2022
Copy link to clipboard 
Print this post

  Quote   If a colon appears immediately after the subroutine name, the subroutine doesn't appear to be called at all.

With the semicolon as the last character of the first 'word' on a line,
the interpreter assumes you are creating a line label.

Jim
VK7JH
MMedit
 
vegipete

Guru

Joined: 29/01/2013
Location: Canada
Posts: 1132
Posted: 04:53am 22 Jun 2022
Copy link to clipboard 
Print this post

  TassyJim said  the interpreter assumes you are creating a line label.

Makes sense, I suppose. Made for puzzling program behaviour until I figured out the 'work-a-round' of adding a space, or a new line.

From the manual "A variable name or a label must not be the same as a function" but says nothing about a subroutine.
Visit Vegipete's *Mite Library for cool programs.
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025