January 20, 2022, 07:49:50 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Sub call from another sub's return

Started by GWS, November 30, 2010, 09:58:58 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

GWS

Hi folks,

I've not seen this before .. I wonder if it has any uses ?  ::)


openconsole
def once:int
Once = 0

While inkey$ = ""
    If Once = 0
        FuncOne()
    EndIf
endwhile

closeconsole

end

sub FuncOne()
    print( "Function One!" )
return FuncTwo()

sub FuncTwo()
    print( "Function Two!" )
    Once = 1
return


Is it any different from calling 'FuncTwo' from the body of  'FuncOne' ?

best wishes, :)

Graham

Tomorrow may be too late ..

LarryMc

In the code that I just posted for sapero there is a function that has a
return function() line in it.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

GWS

Well so there is ..  :o

What a coincidence .. I found my converted example on another website ..  :)

How on earth did you come up with your usage Larry ?  I thought a 'return' could only handle a single value.

I wasn't even sure it would 'compile' .. but it did ..  ;D

best wishes, :)

Graham
Tomorrow may be too late ..

Egil

Interesting...
Is there any special reason to enclose the strings to be printed by parentheses?

Reagards

Egil
Support Amateur Radio  -  Have a ham  for dinner!

LarryMc

Quote from: GWS on November 30, 2010, 10:53:21 AM
How on earth did you come up with your usage Larry ?  I thought a 'return' could only handle a single value.
I've seen it more than once but that specific piece of code came from the old pyxia forum CD.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Yeah...looks cool...
I see something similiar in some Joske example.
Here is one GUI example:
'call-func2
Def win:WINDOW
WINDOW win,0,0,400,300,@minbox,0,"MainGUI",main
SetWindowColor win,rgb(220,220,230)

Function1()

WAITUNTIL win=0
END

SUB main
SELECT @CLASS
Case @IDCLOSEWINDOW
CLOSEWINDOW win
ENDSELECT
RETURN

SUB Function1()
'
Return Function2()

SUB Function2
CONTROL win,"B,SET,50,100,121,25,0x50000000,1"
Return
forum for hobby programming:<br />https://aurelsoft.ucoz.com

GWS

Hmm .. I'd not noticed it before ..  :)

Well spotted Egil, I hadn't fully 'translated' the example .. CB version would be ..


openconsole
cls

FuncOne()

do:until inkey$<>""
closeconsole
end

sub FuncOne()
    print "Function One!"
return FuncTwo()

sub FuncTwo()
    print "Function Two!"
return


But I'm not sure how it differs from how I would normally have coded it ..


openconsole
cls

FuncOne()

do:until inkey$<>""
closeconsole
end

sub FuncOne()
print "Function One!"
FuncTwo()
return

sub FuncTwo()
print "Function Two!"
return


Unless there is some useful reason to use 'Return' for this purpose, it seems to be venturing into the obscure ..  :P

You have a good memory Aurel .. Trust Joske to turn up something unusual ..  :)
I wonder where he's got to .. I miss his contributions ..  ;D

best wishes,

Graham

Tomorrow may be too late ..

Egil

Well, I asked because your example works equally well with or without the parentheses. Usually any "deviation" from what's "normal", mean something special. so I just had to ask. :)
Support Amateur Radio  -  Have a ham  for dinner!