Gosub error with include files

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

Gosub error with include files

Post by shamigc » Tue Nov 09, 2010 1:32 am

Hi,

I have windows 7 and Macro Scheduler Pro 12, and a mapped network drive V: where I want to keep all MS scripts, and started creating two libraries:

V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos\Libreria.scp
V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos\LibreriaAutomatizacion.scp

and the main script that calls these two libraries is located at:

V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos\Archive0PorComando\pruebalogin.scp

and this is the pruebalogin.scp code:

Code: Select all

// COMPILE_OPTS|C:\Users\Owner\Desktop\pruebalogin.exe||CONSOLE=0|INCLUDES=1|
//Set IGNORESPACES to 1 to force script interpreter to ignore spaces.
//If using IGNORESPACES quote strings in {" ... "}
//Let>IGNORESPACES=1

'**************** Constantes
Let>Path=V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos
Include>%Path%\Libreria.scp
Include>%Path%\LibreriaAutomatizacion.scp
GoSub>LeeParametros
GoSub>AsignaIP
GoSub>TeclasCtrl
Let>Ver=10.11.08
Let>APP=Archive0 IBM Produccion-
ConCat>APP,%Ver%
Let>APP_TITLE=%APP%
'Let>Usuario=saoso
Input>USER,Favor de proporcionar el usuario:,heas666l
Let>INPUT_PASSWORD=1
Input>PASSWORD,Favor de proporcionar el password:,password
Let>INPUT_PASSWORD=0
Input>VERIFICACION,Favor de proporcionar el texto que verifique login:,Conectado a : mon_lan
Input>QUIT,Favor de proporcionar el texto de salida correcta del usuario:,0%CR%
GoSub>PruebaLogin
MessageModal>RPL
When I run pruebalogin.scp from macro scheduler works allright, but when I create the exe and run it, I get the following error:

Error in: pruebalogin.exe
Line: 8 - Subroutine/Label LeeParametros Not Found!

And that subroutine does exist inside the second library and works allright when I run macro from Macro Scheduler, but fails executing exe file.

Can you please help me?

Thanks,
Salvador
Thanks,
Salvador Hernandez

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Tue Nov 09, 2010 5:23 am

I don't know that I can help you but I did make a couple of scripts, one that has a subroutine and one that includes that script and calls the subroutine. I placed the included script on my second computer in a subdirectory of a shared folder. The sub ran when I executed the calling script. Then I compiled the calling script including its includes. The sub still ran fine.

Both computers are running Windows XP so perhaps its a Win 7 issue.

The compiled script.

Code: Select all

// COMPILE_OPTS|C:\Documents and Settings\dick\My Documents\Macro Scheduler 12\run test.exe||CONSOLE=0|INCLUDES=1|
Include>S:\2010 Printed_files\test.scp
GoSub>Test

MDL>done
The included script.

Code: Select all

SRT>Test
  MDL>good
END>Test

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Nov 09, 2010 9:01 am

Are you compiling with the "Compile Includes" checked or unchecked? If NOT checked can the exe "see" the include file (the path is accessible to the exe).

Also, at the risk of stating the obvious, if you are calling subroutines that are inside an include file then that include file needs to be included BEFORE you call the subroutine.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

Post by shamigc » Tue Nov 09, 2010 12:14 pm

mtettmar wrote:Are you compiling with the "Compile Includes" checked or unchecked?
Answer is positive, "Compile Includes" is checked, you can see it at first line of code:

Code: Select all

// COMPILE_OPTS|C:\Users\Owner\Desktop\pruebalogin.exe||CONSOLE=0|INCLUDES=1|
mtettmar wrote: If NOT checked can the exe "see" the include file (the path is accessible to the exe).
About exe, even when "Compile Includes" is checked, also exe can "see" included files, it's located at the desktop of the PC that has the mapped network drive V:
mtettmar wrote: Also, at the risk of stating the obvious, if you are calling subroutines that are inside an include file then that include file needs to be included BEFORE you call the subroutine.
In the following lines of code you can see that I first define a variable "path" where included files are located, then I include library files, and then I call a subroutine named "LeeParametros", so I do include files before calling its subroutines. :) The funny thing about this is: Why everythig works allright when I "run" it from macro scheduler, but exe does not work?

Code: Select all

Let>Path=V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos
Include>%Path%\Libreria.scp
Include>%Path%\LibreriaAutomatizacion.scp
GoSub>LeeParametros
I have one additional question: Do I need to have included files in the same directory as the file that calls them? in my case, files included are one level above the file that calls them.
Thanks,
Salvador Hernandez

shamigc
Junior Coder
Posts: 37
Joined: Wed Oct 22, 2003 11:38 am
Location: Monterrey, Mexico

Post by shamigc » Tue Nov 09, 2010 7:06 pm

I found a workaround :wink: , but there is something to be fixed by macro scheduler creators, the problem is variable %Path% is not correctly substituted when an exe is created.

My original code, that gives error "Subroutine/Label LeeParametros Not Found! is:

Code: Select all

Let>Path=V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos
Include>%Path%\Libreria.scp
Include>%Path%\LibreriaAutomatizacion.scp
When I replace variable %Path% value by its value at the code, everything works allright:

Code: Select all

Let>Path=V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos
Include>V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos\Libreria.scp
Include>V:\Mis documentos\Macro Scheduler 11\Oficina\GGG\ProcesosIBM\Respaldos\LibreriaAutomatizacion.scp
Could you please fix this problem next macro scheduler version?
Thanks,
Salvador Hernandez

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Nov 09, 2010 7:18 pm

You said you are compiling includes. The compiler does not run the script and therefore cannot evaluate variables at compile time. It can therefore only compile includes where the path is static (an exception is the SCRIPT_DIR variable). By using a variable the include cannot be compiled statically.

If you UNCHECK the "Compile Includes" option at compile time the problem is solved.

However, you should not have to do this. The bug here is that it doesn't fall back to dynamic includes in the case that the include file cannot be located during compile time or if the include line cannot be resolved at compile time due to a runtime variable.

So, problem has been noted and it will be fixed in next maintenance release.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts