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.
plasma Guru Joined: 08/04/2012 Location: GermanyPosts: 437
Posted: 03:14am 10 Nov 2014
Copy link to clipboard
Print this post
MkII last update
Dim a as integer
A =1234
Test (a)
End
Sub test(a)
Dim b as integer
b= a
Print b
Print a
End sub
This works iirc only for small int's .
If you call the test sub with big int's
Print a shows. XxxxxE^xx
Looks like a casting problem.
Cant test it because iam at work, can anyone confirm ?Edited by plasma 2014-11-11
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676
Posted: 04:00am 10 Nov 2014
Copy link to clipboard
Print this post
Sub test(a) should be Sub test(a%)
PeterThe only Konstant is Change
plasma Guru Joined: 08/04/2012 Location: GermanyPosts: 437
Posted: 04:04am 10 Nov 2014
Copy link to clipboard
Print this post
Ah ok thx
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676
Posted: 04:38am 10 Nov 2014
Copy link to clipboard
Print this post
The formal parameter 'a' in Sub test(a) is NOT the same thing as the variable 'a' declared earlier. The formal parameter 'a' in Sub test(a) says that Sub test is expecting a floating point single variable and hence MMBasic will convert what you supply into a single floating point variable and pass that value into Sub test.
At least that's my understanding
PeterThe only Konstant is Change
plasma Guru Joined: 08/04/2012 Location: GermanyPosts: 437
Posted: 05:55am 10 Nov 2014
Copy link to clipboard
Print this post
I thinking the wrong way before.
Its clear ,a parameter from the sub arguments needs
a declaration inside.
I used this millions times before but nether
About why,only what.
I dunno why i think a dim is all i need , maybe
Glbasic,Bmax or an other compiler is using this.
G8JCF Guru Joined: 15/05/2014 Location: United KingdomPosts: 676
Posted: 07:35am 10 Nov 2014
Copy link to clipboard
Print this post
Try doing Option Default Integer, that should make it all work as you had it before, but not good practice IMHO. Explicit declaration of all variables should lead to more error-free code.