Official ScriptUO EasyUO Scripts > Scripting Chat

Calling scripts and Execution ?

(1/1)

Superslayer:
I'm a little confused on what the command is exactly and how. I understand that it finishes with 'exit' but the parameters are not clear to me. Example, my script is held in folder "C:\My Docs\EUO\My Scripts\test.txt" , exactly as is, spaces included. I also use the text reading program GetDiz (if that matters at all). So in my script calling the sub, should it read:


--- Code: ---call C:\My Docs\EUO\My Scripts\test.txt

--- End code ---

Or as the euo site recommends


--- Code: ---correct: C:\MyDocu~1\blabla.txt

--- End code ---

Namely the squiggly line in front of the '1' shortening the name in all spaces as mine would have two of them. Further, in the called script, does the first line have to have anything at all relating to the name of the script, or its calling, or can it start immediately with code?

Or...
Can I get away with just doing it like this?


--- Code: ---call test.txt

--- End code ---

I've already tried many different methods and variations to no avail.  I'm sure every change I made knocked it off in some way or another and obviously have not had success with it.



One more thing, please anyone take a look at my script in debug please . Four, almost 5 days without a download... :'(

Xclio:
The bottom method that you have will work perfectly fine for you assuming that the EUO Executable, Your Script, and your script that you want to call are all in the same folder.  In fact that is the most reliable method in my opinion.

TrailMyx:
Whatever script you are calling can begin with just code; you don't need anything special.  In fact, I created a snippet that I use for scripts that I want to be able to call *AND* just run.  There is a 1 argument shift in subroutines when you call them vs. when you just gosub to them.


--- Code: ---set !TM_FunctionCalled #FALSE
if %0 = 1 && !TM_FunctionCalled = #FALSE
  gosub %1
if %0 = 2 && !TM_FunctionCalled = #FALSE
  gosub %1 %2
if %0 = 3 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3
if %0 = 4 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4
if %0 = 5 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5
if %0 = 6 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6
if %0 = 7 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7
if %0 = 8 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8
if %0 = 9 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9
if %0 = 10 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10
if %0 = 11 && !TM_FunctionCalled = #FALSE
  gosub %1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11
if %0 > 11
{
  display ok Too many arguments for "call", edit file.
  stop
}
 
if !TM_FunctionCalled = #TRUE ; successfully called function.
  exit
if %0 = N/A
  display ok You may not run this script directly.
else
  display ok Function " , %1 , " not found.
stop
 
;---------------------------------------------------------------
; Put your code under this comment.
; Sample code below, not needed for you.
 
sub SampleSub
  ; your code....
  ;
  set !TM_FunctionCalled #TRUE ; add this line when you return from your subs to let the calling routine know the subroutine was found.
return

--- End code ---

With this code, you can use any subroutine as a called function without having to rewrite it to take into account the argument shift.

Superslayer:
Thanks everyone, that now makes sense since I've tried the last calling method with no success as the euo exe is not in the same folder and whatnot.

Thats a great snippet TrailMyx, I'll definitely look into that in the event this script becomes that complex

TrailMyx:

--- Quote from: Superslayer on December 23, 2008, 11:28:59 AM ---Thats a great snippet TrailMyx, I'll definitely look into that in the event this script becomes that complex

--- End quote ---

Ya, I got tired of trying to maintain two separate versions of my subs, one that you can call and one that you can gosub to.  With that snippet, you get a few things:

1) call or gosub compatibility
2) error checking to see if routine successfully called (i.e. misspelled call name)
3) error checking if you have too many arguments.
4) warning if you try to run the file directly.

Navigation

[0] Message Index

Go to full version