Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I need to put restricted data in a field using an If() statement in a script.

Basically it comes down to those 4 steps, and it is working well:

if value in numberField1 = 400 and value in numberfield2 is higher than zero

set field numberField 3 to numberField2

if value in numberField1 = 400 and value in numberfield2 is lower than zero

set field numberField4 to numberField2

if value in numberField1 = 440 and value in numberfield2 is higher than zero

set field numberField 3 to numberField2

if value in numberField1 = 440 and value in numberfield2 is lower than zero

set field numberField4 to numberField2

Now I have to add an additional If step to make it possible that all the values lower and higher than 400 or 440 (even the in between), with the same restriction for higher or lower than zero, are put in numberfield5

I managed to have the value in numberfield5, but each time there’s also a value in numberfield3 or numberField4.

I see the logic of that as I look to the syntax.

How to write the correct syntax to have the setField working properly and put the right value in numberfield5 ?

TIA

Posted

Hi

if I have understand correctly, change all those steps to:

Set Field [ numberField3 ; If (( numberField1 = 400 or numberField1 = 440 ) and numberfield2 > 0 ; numberfield2 ;"") ]

Set Field [ numberField4 ; If (( numberField1 = 400 or numberField1 = 440 ) and numberfield2 < 0 ; numberfield2 ;"") ]

Set Field [ numberField5 ; If ( numberField1 ≠ 400 or numberField1 ≠ 440 ; numberfield2 ; "" ) ]

BTW: isn't better an autoenter calc ( or even a calculation ) for field3, field4 and field5 ? Why a script ?

Posted

Thanks for solution Daniele.

And no, a calculation doesn't fit here.

It's part of a script to tranfer data from a table with globals input data fields to different tables with regular data fields via Set Variable.

It's part of a lab process where the start is steered by script parameter.

I prefer to hold the process in scripts, where I can break it down into smaller parts.

Most of the fix parts are indeed in calcs, but where it comes to go in different directions I rather like to work with scripts, where I find it easy to change just a little part if needed.

That way I don't have to worry that I break something down the road without notice.

Posted (edited)

...and btw, there's now an other restriction where I can't find the right combination:

numberField3 = if numberField1 = 400 and numberField2 > 0.

numberfield4 = if numberField1 = 400 and numberField2 < 0.

numberfield5 = if numberField1 = 440 and numberField2 > 0.

numberField6 = if numberField1 = 440 and numberField2 < 0.

numberfield7 = if numberField1 (is not)= 400 or 440 and numberField2 > 0.

numberfield8 = if numberField1 (is not)= 400 or 440 and numberField2 < 0.

When I try to use your logic from above I still get values in 2 different fields.

There is no problem when the restriction is limited to 400 or 440, the moment I add the (not) 400 or (not) 440 limit, it goes wrong....

...and now I realize all of this is in the wrong forum, it should be better in the ScriptMaker forum...can somebody move those posts ?

Edited by Guest
Basically post isin wrong forum
Posted

The thread doesn't need to be moved. It is regarding a calculation which is USED by a Set field script-step; nothing more. The focus is the calc logic. :wink2:

Posted

I am puzzled why do you need 6 fields for this. I would set ONE field with an index number between 0 and 5. Then, if required, the 6 fields can calculate their content from the index.

The index can be calculated as =

( numberField1 = 400 ) + 2 * ( numberField1 = 440 ) + 3 * ( numberField2 > 0 )

Posted

@ LaRetta ??? Thanks, I didn't look at it from that point of vue.

@ Comment : also a different point of vue.

But here I'm lost.

Care to elaborate ?

I'm still in the learning stage, and here I'm lost.

Although I see a logic in your calc, but I have no idea about the how to implement...

Thanks

Posted

It's hard to advise without knowing what is your purpose. I merely raised an eyebrow at what you have described, which seems to be:

1. User enters 2 values;

2. You take ONE of the values and put it in a slot (one out of six);

3. You throw away the second value.

Perhaps if you explained what this excercise is designed to achieve, we could think of a better way.

Posted (edited)

To make a long process short, it's kind of hard to explain...

During lab test the user fills in a table/layout with global fields.

Time of input can be between a few minutes and several weeks, depend of the process on hand andthe results.

Once all the needed fields has data (a behind screen control), a 'Register' button is made active/available.

The attached script will tranfer the data to appropriate tables/fields.

The behind screen control above will reduce the data to:

a 400 type 1 (text) and a numbervalue higher or lower than zero,

or a 400 type 2 and a numbervalue higher or lower than zero,

or a 440 type 1 or a 440 type 2, both with a numbervalue higher or lower than zero.

Each process is ending up in 1 text field with a description and 1 numberfield with a value.

This was working well untill there was a need to transfer also end values that are NOT type 400 or 440 and a numbervalue higher or lower than zero.

So, ending up with 8 possibilities, I have now 16 possibilities to test for and tranfer the data to the right field.

The script has now a serie of Set Variables for the 400/440 series, but I'm stuck how to add the not 400/440 series.

The not 400 or 440 types are between 000 and 900.

Those types are specific lab desriptions where the user is familiar with.

I hope I didn't confuse more now....

Edited by Guest
Posted

hope I didn't confuse more now....

No, but I am afraid you didn't make it any more clear either.

process is ending up in 1 text field with a description and 1 numberfield with a value.

OK, so why not just keep those two? If you need to classify the record based on whether type is 400/440/other and number is below/above zero, this classification can be calculated, in a calculation field. Why do we need to "tranfer the data to the right field"?

BTW, 3 possibilities for type * 2 possibilities for number = 6 possibilities in total. How do you figure 16?

Posted

OK, so why not just keep those two?

That's what we do, in the input table, but they are globals.

If you need to classify the record based on whether type is 400/440/other and number is below/above zero, this classification can be calculated, in a calculation field.

They finally are

Why do we need to "tranfer the data to the right field"?

On the input layout there's a dimmed 'register'button. As long as pre-defined fields are empty, this button stays dimmed.

When the pre-defined data is available, this button changes to 'active' and the script can be triggered, to put the final data in the right table/fields, empty the globals in the start layout and make that layout ready again for a new input.

BTW, 3 possibilities for type * 2 possibilities for number = 6 possibilities in total. How do you figure 16?

Euh,

01. 400 type 1 > 0

02. 400 type 1 < 0

03. 400 type 2 > 0

04. 400 type 2 < 0

05. 440 type 1 > 0

06. 440 type 1 < 0

07. 440 type 2 > 0

08. 440 type 2 < 0

and all this again for not = 400/440 > or < 0

= 16.

Or do I see it too complicated ?

Posted

I am sorry, but you have lost me completely. I suggest you give your fields names we can understand.

Global fields are not keepers. I understood that there are two pieces of data here ("1 text field with a description and 1 numberfield with a value"). I am asking (again)B) why is your permanent record not made up of two fields to hold these two pieces of data, and one calculation field that classifies the record as one of 6 possible types/classes/categories (I still see only 6)?

Posted

Maybe that part was not very clear because the problem I have is only with the numbervalue.

The description is a textvalue that goes from the global(text) into a text field, no problem there.

My permanent record is made of two fields (and more).

1 text (no problem) and there are 4 possible permanent numberfields to hold the numbervalue.

After all that makes 6 in total, you're right.

As long as I have only the 400 or 440 range, there is no problem to have the right numbervalue in the rigt numberfield (value higher or lower than 0).

Permanent NameField:

400H0 - for 400 value + 0

400L0 - for 400 value - 0

440H0 - for 440 value + 0

440L0 - for 440 value - 0

not400H0 - for not400 value + 0

etc for the not 400/440 range

With the If() and $SetVariable() in the script I can 'SetField' the right numberfield:

SetField(tableName::400H0;

Case($descriptionIsotope = 400 and $valueIsotope > 0;Abs($valueIsotope);"")

SetField(tableName::400L0;

Case($descriptionIsotope = 400 and $valueIsotope < 0;Abs($valueIsotope);"")

This went very well for the ranges 400 and 440.

SetField(tableName::not400H0;

Case(

$descriptionIsotope ≠ 440000 or $descriptionIsotope ≠ 400000 and $valueIsotope < 0; Abs ( $valueIsotope );""),

gives problems.

The right value comes into the right field for the not400 or not440 range, but also in one of the 400/440 range.

That is normal, vue the If() statement.

A 400 range value IS after all a not440 range value and vice versa.

And that's the problem. By adding the not400/440 range, my If()'s doesn't work anymore.

Posted

I am sorry, but this makes less and less sense.

there are 4 possible permanent numberfields to hold the numbervalue

Why?

there is no problem to have the right numbervalue in the rigt numberfield (value higher or lower than 0).

Again, why? If there's only one value, what advantage is there in putting in the "right" field? Why not have ONE field for the value, whatever the value happens to be?

I am also confused by your use of the word "range". 400/440 is not a range.

Posted

This is to prepare the data to be imported into another program (not FM).

This program requires the fields.

For years the 4 numberfields were enough, together with a description field.

After an upgrade we have to add an additional control for non 400/440 (ok, drop the word range - that's how we call those values intern).

Well, I made a rough little file with the process, without the not400/440 part, maybe this will clear something up....

TIA

Isotope_Lab.zip

Posted

Comment, thanks for all the efforts, I have it working.

instead of:

numberfield7 = if numberField1 (is not)= 400 or 440 and numberField2 > 0.

numberfield8 = if numberField1 (is not)= 400 or 440 and numberField2 < 0,

I use:

numberfield7 = if (numberField1 (is not)= 400 and numberField2 > 0) or (numberField1 (is not)= 440 and numberField2 > 0).

numberfield8 = if (numberField1 (is not)= 400 and numberField2 < 0) or (numberField1 (is not)= 440 and numberField2 < 0)

and it fits the need.

It is maybe not 100% FileMaker Script/calculation art, but it's working.

I will look atit again when my dev level is 1 step higher.

Again, Comment, thank you for your patience..

This topic is 6568 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.