Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:55 05 Jul 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 : A new Bug or is it me ?

Author Message
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 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 Kingdom
Posts: 676
Posted: 04:00am 10 Nov 2014
Copy link to clipboard 
Print this post

Sub test(a) should be Sub test(a%)

Peter
The only Konstant is Change
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 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 Kingdom
Posts: 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

Peter
The only Konstant is Change
 
plasma
Guru

Joined: 08/04/2012
Location: Germany
Posts: 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 Kingdom
Posts: 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.

Peter
The only Konstant is Change
 
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