Official ScriptUO EasyUO Scripts > Script Debug

Sub in a Sub???

(1/4) > >>

xxcaptainxx:
can you have a sub within a sub???  i think so but i would hate to waste a lot of time trying to code an uncodeable :)  thanks all

talkmill:
I'm not a pro at this at all but did some tests. Some pro please correct me if i'm wrong but it seems like:


--- Code: ---sub test1
sub test2
return
return
--- End code ---

work the same way as:


--- Code: ---sub test1
return

sub test2
return
--- End code ---

What exactly is it you are trying to acomplish?

xxcaptainxx:
Well in one of my subs i want to check if i have a certain resource and then if i don't i want to run another sub to restock it

TrailMyx:
Sub in a sub is bad form.  I never do it; it makes code difficult to read and harder to debug but can work if you implement it correctly.  I would stay away from that kind of programming practice is I was you.

With that said, even some coding pros (Kal In Ex) use subs in subs.  I guess if you know what you are doing then you can do anything...

talkmill:
Do you meen something like this?


--- Code: ---sub stockresources
gosub checkresources
if #return < %wantedresources
  gosub restockresources
return
--- End code ---

if thats the case i would say calling other subs from other subs should be done if it helps understandability/abstraction. Otherwise not :)
But then again i'm much more used to other programming languages then easyuo so i probably should be quiet (have a hard time doing that though  ;D )

Navigation

[0] Message Index

[#] Next page

Go to full version