Tap Forms Database Pro for Mac, iPhone, iPad and Apple Watch › Forums › Script Talk › Passing parameter data to Form level Script
Tagged: parameters form script, scripts
- This topic has 3 replies, 3 voices, and was last updated 4 years ago by
Daniel Leu.
-
AuthorPosts
-
June 5, 2022 at 12:04 PM #47434
Bernie McGuireParticipantI want to have a Form Level Script (DoSomething) that accepts an input parm ex DoSomething(‘abc’).
I’d like to call this script from various field level scripts using runScriptNamed(‘DoSomething’) but I do not see how to pass the value of ‘abc’ into the script on the runScriptNamed call.
Is it possible?
Thanks
BernieJune 5, 2022 at 2:06 PM #47438
BrendanKeymasterIf you setup a variable and populate it before you call
runScriptNamed()then you should have access to that variable from within the script you’re running. So no parameter required.June 5, 2022 at 3:58 PM #47442
Bernie McGuireParticipantyou mean the Form Script will have access to a variable declared in a Field Script function ??? are all your vars global? this sounds strange to me.
What I understand is this:
function FieldScript() {
var xyz = ‘123’
form.rundScriptedNamed(‘formScript’);
}Then in the Form Script:
function formScript() {
var abc;
//I can set abc = xyz
abc = xyz;
// and now abc will have ‘123’ in it ?
}
This doesn’t make any sence to me thinking about rules of encapusalation. Unless there is some type of ‘Global’ tag I need to use on the variable.Please help
ThanksJune 5, 2022 at 9:45 PM #47445
Daniel LeuParticipantI use several scripts as infrastructure/include scripts. They only contain function or constant definitions. Then I use
runScriptNamed()to include these functions. Later, whenever I need, I can call one of these defined functions from these include files.So for your example, define
function formScript(abc) { console.log(abc) }Then from your calling script, you do
runScriptNamed("myIncludeScript")
and then later
formScript("hello")Cheers, Daniel
---
See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks -
AuthorPosts
You must be logged in to reply to this topic.