You could uses a global definition:
Script a:
global g_UserName
put {Name:“Bob”, Age:“17”} into g_UserName
To consume it in another script (or different function) you first have to re-define the same global name and then you can consume the value.
Script b:
global g_UserName
…use values here…
You can also load it as a CONST. I dont think you have to constantly re-define a CONST in order to access it though… so easier to consume but more cumbersome to set. I have not used CONST but am considering looking into it.
If, like me, your scripts are heavily functionalised, the CONST route may be a better approach to save missing the redefinition in EVERY function that uses it.
You have to pass the variable to Script B. there are a number of ways to do this. As a Global, as a suite variable, write it to a resource, or (the easiest) send it when you call Script B:
Script A looks like this:
put {Name:"Bob", Age:"17"} into userName
run "Script_B" userName
But really, for simple data fetching of this sort I would make the username data a function:
Script A looks like this: Log ("Handlers".userName).Name
Script “Handlers” looks like this:
to userName
put {Name:"Bob", Age:"17"} into userName
return userName
end userName
I actually really like the functinliase idea… kind of like just hand-cranking a bunch of read-only properties, without the need for the global re-declaring business…
Coming from a dev background I was hung up on the “global” keyword and being frustrated by how it [doesn’t] work… this has changed how i have been thinking about things
Hi Siti,
There ist another useful approach top solve your task. Remember that EP is a object-oriented language. Put into a.script
Properties
Name: “Bob”,
Age: 17
Ende Properties
In Your b.script You can work with
set myA to a new object of a
Put merge(“The age of [[myA.name]] is [[ myA.age]]”) – The age of Bob is 17