Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 13:42 19 Apr 2024 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 : CMM2 variable types in SUBs and FUNCTONs

Author Message
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 01:31pm 06 Mar 2021
Copy link to clipboard 
Print this post

Hi,
is there any reason, why variable types in SUBs or FUNCTIONs can't be decalred by type before variable?
SUB test(INTEGER a, b)
END SUB


I know it's possible
SUB test(a%, b%)
END SUB

or
SUB test(a AS INTEGER, b AS INTEGER)
END SUB


But I'm using usually DIM INTEGER a, b because:
1. I can assign the value or values
DI INTEGER a = 3, b = 5

2. can be more variables of same type in one declaration

So right now I'm mixing because of it 2 different approaches in FUNCTIONs/SUBs and anywhere else...
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 8566
Posted: 02:17pm 06 Mar 2021
Copy link to clipboard 
Print this post

  Quote  is there any reason, why variable types in SUBs or FUNCTIONs can't be decalred by type before variable?


Can everyone stop challenging core MMBasic syntax - it is not going to change.
In this case the parsing would be difficult as subroutines can have different types for different parameters so you would have to keep context until the next type - not something which is or will be supported

If your program is predominantly integer then use OPTION DEFAULT INTEGER
Edited 2021-03-07 00:17 by matherp
 
jirsoft

Guru

Joined: 18/09/2020
Location: Czech Republic
Posts: 532
Posted: 03:34pm 06 Mar 2021
Copy link to clipboard 
Print this post

Hi Peter,
it was not meant as offence, I have just asked the question. For me was strange, that in DIM I have 3 ways and in SUBs/FUNCTIONs just 2, so I have thought it's some mistake (if they were just the same 2 in DIM, I wouldn't asked).

So clear answer and I'm OK with it.
Jiri
Napoleon Commander and SimplEd for CMM2 (GitHub),  CMM2.fun
 
Print this page


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

© JAQ Software 2024