It is currently Wed Aug 21, 2019 5:14 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Select + Goto
PostPosted: Sat Aug 04, 2018 1:31 am 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 21
Select + Goto inside always = Stack corruption.

Very basic example:
Code:
Procedure test(val)
  Select val
    Case 1
      ;Do something
    Case 2
      ;Do something
    Default
      Goto finalize
  EndSelect
 
  ;Do something else
  ProcedureReturn #True
 
  finalize:
  ;cleanup
  ProcedureReturn #False
EndProcedure

test(0)


I think this can be fixed.


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 1:52 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1893
It's not a bug if the manual says not to do it:

Manual for 'Goto' wrote:
never use it inside a Select/EndSelect block

;)


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 2:19 am 
Offline
User
User

Joined: Sat Jul 07, 2018 6:50 pm
Posts: 21
True :)
Quote:
never use it inside a Select/EndSelect block (Unless you have the ability to manage the stack yourself, correctly.)

Not a big deal to fix stack manually, or use alternatives. My bad, don't read the docs first, now I know, thx!


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 1:25 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Mar 02, 2004 1:20 pm
Posts: 1014
Location: Amphibios 9
Manual for 'Goto' wrote:
never use it

;)

_________________
Can't decide if i need a hug, an XXL coffee, 6 shots of vodka or 2 weeks of sleep.


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 1:32 pm 
Offline
Addict
Addict
User avatar

Joined: Wed Aug 31, 2005 11:09 pm
Posts: 3694
Location: Italy
Manual for 'Goto' wrote:
use it

;)

_________________
[ My little PureBasic review ]


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 1:50 pm 
Offline
Addict
Addict

Joined: Wed Nov 12, 2008 5:01 pm
Posts: 1050
Location: Russia
Code:
Procedure test(val)
  Select val
    Case 1
      ;Do something
    Case 2
      ;Do something
    Default
      FakeReturn
      Goto finalize
  EndSelect
 
  ;Do something else
  ProcedureReturn #True
 
  finalize:
  ;cleanup
  ProcedureReturn #False
EndProcedure

test(0)

_________________
Library XP_Menu_Lib - office menu; HID_Lib - USB Library
Torrent client - pbTorrent (source code); Create driver in PureBasic.


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 3:24 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 882
User_Russian wrote:
Code:
Procedure test(val)
  Select val
    Case 1
      ;Do something
    Case 2
      ;Do something
    Default
      FakeReturn
      Goto finalize
  EndSelect
 
  ;Do something else
  ProcedureReturn #True
 
  finalize:
  ;cleanup
  ProcedureReturn #False
EndProcedure

test(0)


Good idea. I opened a request in Bugs/Documentation. Look here

_________________
sorry for my bad english


Top
 Profile  
Reply with quote  
 Post subject: Re: Select + Goto
PostPosted: Sat Aug 04, 2018 3:27 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Nov 05, 2006 11:42 pm
Posts: 4487
Location: Lyon - France
@User-Russian
Waouuh !!
Thanks !! i have never see this command :shock:
Here is someone who use time for read the doc :oops:

_________________
ImageThe happiness is a road...
Not a destination


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: BlindMan and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye