Jump to content

Help with event script please


Inky Phil

This topic is 6815 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Can anyone give me a quick tutorial on using eventscript. I have returned to the sample files at least 5 times and spent time trying to work out what to do but I just cannot get my head around it.

All I want to do for now is if a user changes field 1 then set field 2 to null.

Any help would be appreciated I promise I am not just being lazy. I really have tried with this and just cannot grasp it ???

Thanks in advance

Phil

Link to comment
Share on other sites

Which Event Script plugin are you using? If you are using the one from softwareforhumans S4HU, then you need to set the field that you want the user to run the event out of, field1 to calculated value on the Auto enter tab. Make sure that 'Do not replace..." is unchecked.

In your calculated value formula you can use the following code, where Field2NullScript is a script where it sets field2 to whatever you want to set it to.

If ( Get ( ActiveFieldName ) = "field1" ;

If ( S4HU_EventScript(Get (FileName ); "Field2NullScript" ; "" ) = "";

field1; field1

; field1

)

Link to comment
Share on other sites

Hi Mr Vodka

Yes it is the Software for humans that I have.

I will use your code later on and let you know how I get on.

It certainly seems more straightforward than the examples (although I think I am getting paranoid about those now ??? )

Thanks for taking the trouble to help

Regards

Phil

Link to comment
Share on other sites

Mr Vodka ,

Goldarn it !!I still couldn't get it to work :.

After a few attempts (about 2 hours worth ??? ) I have to admit defeat. Not a usual thing for me but my brain is beginning to hurt and I am beginning to hate event driven things!!!!!!!!. I even tried cutting and pasting your code in rather than trying to recreate it and it still gave me a message 'too many parameters for this function'

I have given up and am going back to things I understand,,,,,,,,,,, so I am sat at my desk wondering exactly what I CAN do???.

I just wanted to say thanks again for trying

Grumpy Phil

Link to comment
Share on other sites

I don't use eventscript but just looking at the calculation given

If ( Get ( ActiveFieldName ) = "field1" ;

If ( S4HU_EventScript(Get (FileName ); "Field2NullScript" ; "" ) = "";

field1; field1

; field1

)

There is a missing ")" after the third occurrence of field1 which will lead to your too many parameters error message.

If ( Get ( ActiveFieldName ) = "field1" ;

If ( S4HU_EventScript(Get (FileName ); "Field2NullScript" ; "" ) = "";

field1; field1)

; field1

)

Link to comment
Share on other sites

SlimJim,

Thanks for looking.

Despite my eyes twitching at the thought of revisiting this again (the nested if functions within a routine that I dont understand anyway have really got to me) I will try that because I hate to be beaten.

I wouldn't care but the functionality that this will give me, if I can pull it off, will be so taken for granted by the user that I am getting annoyed with them already !! :wink2:

I will let you know how I get on

Regards and thanks again

Phil

Link to comment
Share on other sites

Going back to your original stated aim could you not use a calculated auto-enter for field2, replace existing value of

If(Get(ActiveFieldName)="field1";"";field2)

This is a very powerful technique in v7 as it allows fields to reference themselves and other fields during auto-enter.

Link to comment
Share on other sites

WOW,WOW,WOW,:giggle::giggle:

How easy was that!!!!!!!!!!!!!!!!!!!!!!

Thank you slimjim and MrVodka.

The good thing is that with all the hastle I had I actually began to understand the coding and now it is working I am off to do lots more

I Love event driven things!!!!!!

Thanks again

Phil

ps no doubt I will be back with my chin on the floor again before too long

Link to comment
Share on other sites

Going back to your original stated aim could you not use a calculated auto-enter for field2, replace existing value of

If(Get(ActiveFieldName)="field1";"";field2)

This is a very powerful technique in v7 as it allows fields to reference themselves and other fields during auto-enter.

Slimjim,

I only saw this post after I posted my last one which referred to using the plug-in.

Thank you for your alternative suggestion but I don't understand how this auto calc in field 2 would know that field 1 had been altered and not just entered. (For that matter I couldn't work out how the plugin knew that either).

Is that the case?. Would it only work if field 1 was changed? If so then it is indeed a handy one to know (still feeling my way around 7).

Even if this is the case, my original stated aim was for test purposes only. Now that I(we) have it working I will be applying it to every field on the layout because I need to trigger a script whenever anyone changes any information.

Regards

Phil

Link to comment
Share on other sites

I don't understand how this auto calc in field 2 would know that field 1 had been altered and not just entered.

I don't think it would know about an actual change in value. For example, if you delete the value in field 1 and then replace it with the same value it would trigger the auto-enter and I rather suspect that simply tabbing into the field and out would do the same but I haven't checked that. I think, but do not know, that the plug-in also is triggered by the field becoming active as opposed to changing but you can easily test that yourself.

Link to comment
Share on other sites

Hi Slimjim,

Thanks for clarifying that.

I have tested the plugin, using the code you gave me, and it does indeed only run the script when the field is altered and not when it is just entered or tabbed into or out of.

For a piece if Freeware that eventplugin by Software for Humans is something else. I really must make a contribution

Regards

Phil

Link to comment
Share on other sites

This topic is 6815 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.