April 18, 2024, 08:21:56 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Declared Subs

Started by aurelCB, June 28, 2009, 03:17:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

aurelCB

Hi ...
What is the advantage of declared sub instead normal sub?
Is this way faster?
For example in big programs.

example with strings:
' connect strings
DEF gw1,gw2,gw3,gw4:string
DEF result$:string
Declare ConectStr(str1:string,str2:string,str3:string,str4:string)

DEF win:window
Window win,0,0,400,300,@minbox,0,"Declare Conect",main
Setwindowcolor win,rgb(230,230,235)
gw1="This ":gw2="is ":gw3="declared ":gw4="conect$"
'--------------------------------------------
'first way
result$ = ConectStr(gw1,gw2,gw3,gw4)
Frontpen win,rgb(200,0,0)
Move win,20,20:Print win,result$
result$=""

'second way
ConectStrings()
Frontpen win,rgb(0,0,200)
Move win,20,50:Print win,result$

'---------------------------------------
waituntil win=0
END

SUB main
select @class
case @IDclosewindow
closewindow win
endselect
RETURN

'first way
SUB ConectStr(str1:string,str2:string,str3:string,str4:string)
def retstr:string
retstr = append$(str1,str2,str3,str4)
RETURN retstr

'second way
SUB ConectStrings
result$=append$(gw1,gw2,gw3,gw4)
RETURN


I'm not sure ,is my example written in right way?