Author Topic: Calling scripts and Execution ?  (Read 2979 times)

0 Members and 1 Guest are viewing this topic.

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Calling scripts and Execution ?
« on: December 23, 2008, 08:15:32 AM »
0
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: [Select]
call C:\My Docs\EUO\My Scripts\test.txt

Or as the euo site recommends

Code: [Select]
correct: C:\MyDocu~1\blabla.txt

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: [Select]
call test.txt

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... :'(

Offline Xclio

  • Officially "The MAN"
  • Elite
  • *
  • *
  • Posts: 981
  • Activity:
    0%
  • Reputation Power: 9
  • Xclio has no influence.
  • Gender: Male
  • Respect: +56
  • Referrals: 1
    • View Profile
Re: Calling scripts and Execution ?
« Reply #1 on: December 23, 2008, 08:59:50 AM »
0
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.

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Calling scripts and Execution ?
« Reply #2 on: December 23, 2008, 10:36:18 AM »
0
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: [Select]
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

With this code, you can use any subroutine as a called function without having to rewrite it to take into account the argument shift.
Please read the ScriptUO site RULES
Come play RIFT with me!

Offline SuperslayerTopic starter

  • Elite
  • *
  • *
  • Posts: 1006
  • Activity:
    0%
  • Reputation Power: 14
  • Superslayer barely matters.Superslayer barely matters.
  • Gender: Male
  • Well what do you drink? Not tea.
  • Respect: +43
  • Referrals: 0
    • View Profile
Re: Calling scripts and Execution ?
« Reply #3 on: December 23, 2008, 11:28:59 AM »
0
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

Offline TrailMyx

  • Officially retired from UO
  • Administrator
  • *
  • *
  • Posts: 13302
  • Activity:
    0.2%
  • Reputation Power: 154
  • TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!TrailMyx is awe-inspiring!
  • Gender: Male
  • Viper!
  • Respect: +1349
  • Referrals: 33
    • View Profile
    • ScriptUO
Re: Calling scripts and Execution ?
« Reply #4 on: December 23, 2008, 11:59:02 AM »
0
Thats a great snippet TrailMyx, I'll definitely look into that in the event this script becomes that complex

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.
Please read the ScriptUO site RULES
Come play RIFT with me!

Tags: