LB Booster
« GLOBAL in SUB isn't global »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:52am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: GLOBAL in SUB isn't global  (Read 424 times)
Dacite
New Member
Image


member is offline

Avatar




PM


Posts: 6
xx GLOBAL in SUB isn't global
« Thread started on: Apr 26th, 2015, 11:07pm »

In LB4, you can declare a global variable in a SUB, but it doesn't work in LBB. It prints 0 in LBB, and 4294967295 in LB4. Something to be aware of...
Code:
call Init
print m32
END

SUB Init
  GLOBAL m32
  m32 = 2^32 - 1
END SUB 


- Dacite
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: GLOBAL in SUB isn't global
« Reply #1 on: Apr 27th, 2015, 06:23am »

on Apr 26th, 2015, 11:07pm, Dacite wrote:
Something to be aware of...

It would be something to be aware of, except that I cannot reproduce it! I copied your code, exactly as listed, into LBB v3.00, ran it, and it printed 4294967295. What do other people get?

Richard.
User IP Logged

Mal
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 3
xx Re: GLOBAL in SUB isn't global
« Reply #2 on: Apr 27th, 2015, 08:26am »

I get the same as you, Richard.

Both gave the same answer.

If lines 5 and 6 are traded, different answers happen.
LBB stays the same; LB gives 0.

Code:
call Init
print m32
END

SUB Init
    m32 = 2^32 - 1
    GLOBAL m32
END SUB  


Malcolm
User IP Logged

Dacite
New Member
Image


member is offline

Avatar




PM


Posts: 6
xx Re: GLOBAL in SUB isn't global
« Reply #3 on: Apr 27th, 2015, 1:49pm »

I'll be d**d - it works for me now too.

But it wasn't working - it was 0 in the later SUB when I was ANDing with it, and 0-ing out my array. The code worked right when I cut/pasted the declaration to the start of the code.

Note to self - In the future, restart LBB and see if the unexpected behavior goes away.

- Dacite
User IP Logged

tsh73
Full Member
ImageImageImage


member is offline

Avatar




PM

Gender: Male
Posts: 210
xx Re: GLOBAL in SUB isn't global
« Reply #4 on: Apr 27th, 2015, 2:32pm »

>>it was 0 in the later SUB when I was ANDing with it

Might it be not integer? LBB rounds to integer before using in logical operations (so sometimes to 0), if I am right.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls