Book a Demo

Author Topic: Call a script from within another?  (Read 8413 times)

Andrew Warner

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Call a script from within another?
« on: February 24, 2010, 09:10:08 am »
Hi all,
is there a method to call a script (e.g. jscript, javascript or vbscript) from within another script. This might have been touched on with the thread about libraries of VBScripts but I couldn't see an answer to this question.

Cheers,
Andrew.
P.S. One use is so I can set up the elusive enums as vars in a central place, rather than having to copy subsets to every script.
Regards,
Andrew Warner.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Call a script from within another?
« Reply #1 on: February 24, 2010, 10:00:27 am »
You can use !INC to include other scripts within your current script.

The syntax is
Code: [Select]
!INC [Script Group Name].[Script Name]
This has the same effect as a #include where the code from the included script is injected into the current script when it is loaded into the script engine. You should then be able to call functions belonging to the included script from the base script.

Example
Code: [Select]
!INC Some Group.My Script To Include
var result = FunctionFromOtherScript();

Note that you can only include scripts that are written in the same language as your base script.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

Andrew Warner

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Call a script from within another?
« Reply #2 on: June 07, 2010, 05:25:39 pm »
Hi all,
sorry about the late addition to this thread but is it true that you can't use the !INC construct to call scripts in an MDG technology group?

I have a bunch of scripts that I've split up and call using !INC. I developed them in a development model and have published them with the MDG technology.

Now the !INC statements seem to crash. The error is
Code: [Select]
Expected ';', Line: 1

By the way, the scripts run fine in the development model where I prepare the MDG technology.

I would rather not have to duplicate the scripts in the modelling model since I might want to use them in several, which will all use the MDG technology.

Cheers,
Andrew.
« Last Edit: June 07, 2010, 05:26:23 pm by adwarner »
Regards,
Andrew Warner.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Call a script from within another?
« Reply #3 on: June 08, 2010, 08:51:33 am »
Hi Andrew,

I'd send a bug report through to Sparx Systems support about that one. If you can include an example technology that reproduces the problem we'll have a look at what's going wrong.
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8

Andrew Warner

  • EA User
  • **
  • Posts: 51
  • Karma: +0/-0
    • View Profile
Re: Call a script from within another?
« Reply #4 on: June 08, 2010, 09:07:17 am »
Thanks Michael but it looks like a PEBKAC. (Problem Exists Between Keyboard And Chair).

I had another !INC in one of the INCed scripts and I hadn't changed the group in that one.

Sorry for the inconvenience.
Regards,
Andrew Warner.

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Call a script from within another?
« Reply #5 on: June 08, 2010, 12:14:59 pm »
Quote
Thanks Michael but it looks like a PEBKAC.

I think it's called a "Carbon Based Error" in the industry parlance. No problems, glad to hear you're on your way again  8-)
Best Regards,

Michael

[email protected]
"It is more complicated than you think." - RFC 1925, Section 2.8