Can I have EXEC_SCRIPT call a function instead of String?

If you have questions or if you want to share your opinion about Aware IM post your message on this forum
Post Reply
BLOMASKY
Posts: 1471
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Can I have EXEC_SCRIPT call a function instead of String?

Post by BLOMASKY »

is it possible to have a file with all of my "functions" that I want to call from my application and then have it included in my app, so I can just have a simple call in my process. something like EXEC_SCRIPT MyScript.myFunction(parameters)


Thanks
Bruce
mrbdrm
Posts: 349
Joined: Tue Oct 16, 2012 11:44 am

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by mrbdrm »

BLOMASKY wrote:is it possible to have a file with all of my "functions" that I want to call from my application and then have it included in my app, so I can just have a simple call in my process. something like EXEC_SCRIPT MyScript.myFunction(parameters)


Thanks
Bruce
+1
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by aware_support »

Well, you can create your own Javascript file with your functions and put the file into Custom/JS directory from where it will be automatically loaded when your app starts up.
Aware IM Support Team
BLOMASKY
Posts: 1471
Joined: Wed Sep 30, 2015 10:08 pm
Location: Ocala FL

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by BLOMASKY »

OK, so assume I do create a file. How do I reference the name of my function?
Do I need to put my functions in a class?
Any samples?

Thanks
Bruce
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by aware_support »

You don't need classes. You can just call it like this:

EXEC_SCRIPT 'myFunction(parameters)'

Just make sure that the name myFunction is globally unique. A good idea is to have a special prefix unique to you/your company:

EXEC_SCRIPT 'bl_myFunction (parameters)'
Aware IM Support Team
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by aware_support »

and in your Javascript file you will define it like this:

function bl_myFunction (parameters)
{
alert ("Function is running!!!");
}
Aware IM Support Team
mrbdrm
Posts: 349
Joined: Tue Oct 16, 2012 11:44 am

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by mrbdrm »

i am having a lot of trouble with this rule.
my js content located in Custom/JS

Code: Select all

function LopenBrowser(LbasedURL) {
	alert(LbasedURL);
		   }
here is what i tried:

Code: Select all

EXEC_SCRIPT 'LopenBrowser(LbasedURL)' 
error Exception running script ReferenceError: LbasedURL is not defined

Code: Select all

EXEC_SCRIPT 'LopenBrowser(/LbasedURL/)' 
function run OK with the parameter value= /LbasedURL/

Code: Select all

EXEC_SCRIPT 'LopenBrowser(/val/val/file.pdf)' 
error Exception running script SyntaxError: invalid regular expression flag v

how can i pass this parameter "/val/val/file.pdf"
aware_support
Posts: 7525
Joined: Sun Apr 24, 2005 12:36 am
Contact:

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by aware_support »

Why don't you do something like this:

EXEC_SCRIPT 'var param1=...; param2=...; LopenBrowser(param1,param2)'
Aware IM Support Team
mrbdrm
Posts: 349
Joined: Tue Oct 16, 2012 11:44 am

Re: Can I have EXEC_SCRIPT call a function instead of String

Post by mrbdrm »

aware_support wrote:Why don't you do something like this:

EXEC_SCRIPT 'var param1=...; param2=...; LopenBrowser(param1,param2)'
it's a single parameter function.
for now i have divided the string to multiple parameters and join them with JS
Post Reply