=0 is not the same as IsEmpty()
& Insert Text is a "paste"
when a Set Field is preferable
If you have 5 buttons and each has a different "text", I believe I would pass the value of the test as a script parameter.
Perform Script ( SET_hazards ; "<<your text here>>" // this will be different for each button )
Set Variable ( $sp = Get ( ScriptParameter ) )
If ( not IsEmpty ( $sp ) // script only runs if you've pass a parameter )
If ( not IsEmpty ( field1 ) )
Set Field ( field1 ; $sp )
Else If ( not IsEmpty ( field2 ) )
Set Field ( field2 ; $sp )
Else If ...
Finish the Else If for the rest of the fields. This will work for every button (passing different text) and all fields. It will go through IN ORDER and find the first empty field, and fill it with the text.
Thank you Beverly, the response is much appreciated!
Again, you'll have to excuse my ignorance here, still struggling a bit.
So, I now have 2 scripts running. 1 is the Perform Script function which I have like this:
Perform Script ["SET_hazards"; Parameter: ""01 Access | egress blocked | restricted work place"]
If I assign this script to the button, it seems to work for the first button press, it certainly dumps the desired text in the first field. Is the 'Parameter' part correct though? That's not in your example but the only place I could see to put it in the 'Specity Script' window was at the bottom in the 'Optional Script Parameter:' field.
Then I have a second script called SET_hazards that looks like this:
Set Variable [$sp; Value; Get ( ScriptParameter )]
If [not IsEmpty ( $sp )]
Set Field [Project Brief::RA Hazard#1; $sp]
Else If [not IsEmpty (Project Brief::RA Hazard#2)]
Set Field [Project Brief::RA Hazard#2; $sp]
This is not working at all. Can you tell me where I've gone wrong please?
The button has one script step and the parameter can be different for each button.
If you have not posted screen shots please send the dialog you assign to the first button.
Sent from miPhone
Show the button dialog
Sent from miPhone
Sorry Beverly, not sure what you mean, how do I find that?
I've decided not to use a button but a checkbox instead. Would this make a difference?
When you create the button, you have the option to assign a single script step or a perform script:
When select single step, type
then select your script:
& add the parameter.
You can duplicate this button for each one, rename the label AND change the "optional script parameter" for each button. That way you are using the same script, but passing different parameters.
Ah ok yes I understand, thanks. However, I'm not using a button any more, I'm using a checkbox. Does the same dialog apply to checkboxes?
For each checkbox, I right click, go to 'set script triggers', then going to 'select' next to 'script:' and selecting the relevant script from the 'specify scripy' window. Is that right?
you did not specify checkbox. Please post a screen shot of your layout with the "buttons" (if any) and the checkbox formatted field. as well the fields you need "filled". and then describe again what steps you are trying to do based on the screen shots.
Seems like it would be much simpler and much more flexible just to add a new related record each time instead of trying to determine which of a set of duplicate fields to which to set with your value.
I mentioned that a few posts ago, apologies for the confusion.
Ok here's the layout:
You can see the 2 checkboxes at the top. There will be a list of 52 of these. Here is what I need:
- When a checkbox is checked, I need the associated hazard title, for example 'Access/egress blocked/restricted (work place)' to load into the next available hazard field at the bottom of the screen.
- When the checkbox is unchecked, I need the associated hazard title to be removed from the fields at the bottom.
Is that enough info? Let me know if you need more. And sorry again for the confusion! Very new at this!
step one: learn about checkboxes
put a text field on the layout and format as checkboxes (assign any valuelist)
put the same field on the layout but do NOT format as checkboxes
now check and uncheck the field with checkboxes
note the values that appear in the same field as you check/uncheck
The VALUES in the field whether formatted or not will appear in the order you add (or remove them). This is a return-delimited list and there are many things that can be done with that list.
Rather than pushing the values into other fields (which can be done), is there any reason to NOT leave as the checkboxes and the values in that field?
Let me know if you understand this step.
Ha you've lost me!
What do you mean by 'format as checkboxes'? So I create a new text field in the field picker and then what? Can't see an option to format as checkboxes.
I was using the Field/Control Tool to create the checkboxes, is that wrong?
When I add a checkbox using this tool, it asks me to link it with a field like this:
It then says 'value list missing' so I go to the 'values from' section on the inspector and then create a new value list with a custom value of 'Animals / insects wild performing etc' or whatever info I want dumped into the fields below when the checkbox is checked. Is that correct?
Thanks again for being so patient!
step two: doing something with the values in a checkbox field
ask yourself if you want the other 5 fields filled as a check box is checked
ask yourself what should happen if you UNCHECK a value - does it get removed from one of the 5 fields
ask yourself if once checked, and placed into a field, can a value be placed into multiple fields
if not filling the fields every time a checkbox is checked, when do you want the other fields filled
how is the value list populated (to make the checkboxes labels)?
because of the structure, a revision, such as suggested by phil might be a better method. but first we need to answer the questions posed above.