ProcedureReturn question

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

Does ProcedureReturn exit a procedure as soon as it's called, or does the
procedure still have to flow through to the EndProcedure command?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

Yes, it returns, see yourself:

Code: Select all

Procedure.l Test()
  ProcedureReturn 1
  MessageRequester("Test","didn't return",0)
EndProcedure
  
;CallDebugger
a = Test()
MessageRequester("","done.",0)
End

--
If it stinks, it's chemistry. If it moves, it's biology.
If it does not work, It's computer science.


Edited by - freak on 07 August 2002 00:48:53
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

You can have several ProcedureReturns like:

Code: Select all

Procedure Australia(Where.s)
  If Where.s = "Sidney"
    ProcedureReturn "Capital"
    ;the procedure ends here
  Else
    ProcedureReturn "Elsewhere"
    ;the procedure ends here
  EndIf
EndProcedure
 
Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Edited by - franco on 07 August 2002 00:53:56
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Procedure.l Test()
> ProcedureReturn 1
> MessageRequester("Test","didn't return",0)
> EndProcedure

Thanks, I should have done a test myself, but had to go out and was
hoping an answer would be here when I got back.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Andre.

Code: Select all

Procedure Australia(Where.s)
  If Where.s = "Sidney"
    ProcedureReturn "Capital"
    ;the procedure ends here
  Else
    ProcedureReturn "Elsewhere"
    ;the procedure ends here
  EndIf
EndProcedure
Just a little note: to use this example correctly, the Procedure.s (keyword with type parameter) must be used. Else the compiler returns a numerical value...

Regards
André

*** German PureBasic Support ***
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.

Code: Select all

Procedure Australia(Where.s)
  If Where.s = "Sidney"
    ProcedureReturn "Capital"
    ;the procedure ends here
  Else
    ProcedureReturn "Elsewhere"
    ;the procedure ends here
  EndIf
EndProcedure
Just a little note: to use this example correctly, the Procedure.s (keyword with type parameter) must be used. Else the compiler returns a numerical value...

Regards
André

*** German PureBasic Support ***
Thanks, I overlooked that (sorry).

BTW: You could also use 'Procedure$'.

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> BTW: You could also use 'Procedure$'.

Yes, but then that procedure won't appear in the drop-down navigator.


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
> BTW: You could also use 'Procedure$'.

Yes, but then that procedure won't appear in the drop-down navigator.


PB - Registered PureBasic Coder
Thanks, I never used the drop-down navigator...

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> Thanks, I never used the drop-down navigator...

How the heck do you navigate your long source codes?


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Franco.
How the heck do you navigate your long source codes?
Long Source Codes? Me? Nop!

Two Words: Include Files

BTW: I stopped coding some weeks ago because of time issues anyway.
Maybe one fine day I have more time and my projects can grow and get bigger and bigger, and I will have long source codes...

@Francois: Had no time to make the changes... If you like, you can release the code as it is. Sorry for that...

Have a nice day...
Franco

Sometimes you have to go a lonely way to accomplish genius things.

Edited by - Franco on 08 August 2002 18:29:42
Post Reply