Triggering one script from another

Moderators: Phil Winkler, Graham Smith, Pete Tabord

Triggering one script from another

Postby Gil Fleming » Fri May 27, 2016 10:28 am

We have a form which is part of a safety data sheet build.

The form has 6 hazard fields (let's say H1 to H6) and 6 precaution (P1 to P6) fields. The user can fill up to 6 fields in total, selected in any proportion from the H or P fields.

For example, we might complete H1, H2, P1, P2, P3. Alternatively, we might complete H1 through H6.

As we enter these fields, content is copied into 6 data sheet fields which are linked to our labelling software. The H and P fields have some fairly complex scripting on their valuechange event to populate these data sheet fields and it works perfectly.

However, if we make a copy of some content via a cloning procedure (some products have virtually identical data sheets), the data sheet fields are not entered as they are script-driven. We have tried to re-trigger the valuechange event by a button script that changes an H field value, then returns it to its original value. The button script successfully changes the H field value, but the H field's valuechange script isn't triggered.

Is this expected?
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 

Re: Triggering one script from another

Postby John Middleton » Fri May 27, 2016 12:20 pm

Gill
What wumble webs we weave!

I can recall doing this kind of scripting in DE 6.5, only for it to run out of memory as apparently too much script was added!!
Passing an instruction from one window to another (Your ‘cloning procedure’ back to your product entry form isn’t easy), but it is doable.
I used to add:

Clear := DocumentClose () .
Close := ClearSelectionFilter () + FormClear () .

At the foot of a procedure, which does reinitiate the opening document.

And I don’t know whether or not you are aware you can post data via e.g.

SALE2.RECORD1.dat.value := concat(SALE2.RECORD1.relSingle.Record1.QUANTITY.value * -1, "#" , SALE2.RECORD1.relSingle.Record1.PLUCODE.value) .
Key := KeyStrokes("_enter") .

And then the ValueChange event will be triggered.

John Middleton
ShopEase
John Middleton
 
Posts: 110
Joined: Mon Sep 10, 2007 3:14 pm
Location: England
Has thanked: 0 time
Been thanked: 1 time
 

Re: Triggering one script from another

Postby Graham Smith » Tue May 31, 2016 12:05 pm

Without having this in front of me to see exactly what you are doing, it's difficult to say. If you are simply copying the value in H1 then pasting it back, then I could see why that wouldn't be seen as a change. If you are copying H1, blanking it, and then pasting the value back, I would expect the script to fire.

However, if you are expecting a cascading change to happen, I rather expect it would not. Scripts are extremely complex critters and it's been my experience that over reliance on them to do things (particularly to manipulate data) is asking for trouble.

If I understand what you are doing, you should be able to do the same thing with derivations. I've done something like that before, although not with 12 separate fields as source, but I can see a possible solution in my head.

Frankly, this sounds like something that would be much better accomplished by a procedure which runs prior to printing. I would be extremely reluctant to do something like this from within a single form.
Graham Smith
DataSmith, Delaware
"For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)
"X-Clacks-Overhead: GNU Terry Pratchett"
User avatar
Graham Smith
 
Posts: 2501
Joined: Fri Sep 07, 2007 11:31 am
Location: Delaware, USA
Has thanked: 0 time
Been thanked: 1 time
 

Re: Triggering one script from another

Postby Gil Fleming » Tue May 31, 2016 12:17 pm

Hello from sunny South Korea!

Graham, I think we will have to go down the procedural route. I was thinking that we would have to mirror our scriptural derivations in a procedure but now I'm wondering if we can just put the target field values into globals and then explicitly write them in by procedure. Praps we've been overthinking it.
Gil Fleming
Director
Fleming Technical Limited

You can't think about what you don't know - Mike Fidler
If you can't fight, wear a big hat - John S Fleming
The best way to have a good idea is to have lots of ideas - Linus Pauling
Gil Fleming
 
Posts: 546
Joined: Tue May 15, 2012 10:26 am
Location: Liverpool, UK
Has thanked: 1 time
Been thanked: 2 times
 

Re: Triggering one script from another

Postby Graham Smith » Wed Jun 01, 2016 11:56 am

Gil, perhaps I'm just a bit old fashioned but I'm something of a believer in keeping things simple. There are some really elegant things you can do with scripting and I have taken advantage of that from time to time. But I have also seen what can happen if you get too carried away.

If you are printing one record at a time, then it would be a simple matter to turn the print function (button or menu item) into something that merely called a procedure and passed it the record ID. All the data needed could be gotten from the record based on the ID. If it's a batch process, then simply set a Print Yes/No flag in the record and print all those with the flag set to yes.

Of course, things always seem easy when you are setting comfortably miles from where the real work is.
Graham Smith
DataSmith, Delaware
"For every expert there is an equal and opposite expert.", Arthur C. Clarke (1917 - 2008)
"X-Clacks-Overhead: GNU Terry Pratchett"
User avatar
Graham Smith
 
Posts: 2501
Joined: Fri Sep 07, 2007 11:31 am
Location: Delaware, USA
Has thanked: 0 time
Been thanked: 1 time
 
 

Return to Ffenics 1.x

Who is online

Users browsing this forum: No registered users and 10 guests

cron