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 RepublicPosts: 532 |
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 KingdomPosts: 8566 |
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 RepublicPosts: 532 |
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 |