Jump to content

simple calculation


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

Recommended Posts

Hi Kelvin,

You haven't really explained much. Which field are you setting? B? Script would be use Insert Calculated Result[] or Set Field[] but I don't know which field we're setting.

Set Field [ B ; not A ]

But there would be no Else (or blank result if A is empty) because boolean translate 0 and blank exactly the same way. And that last Else ... do you mean that, if A is empty you want B to be empty? Aren't empty and 0 the same? Can you provide more information? I doubt you need a script here. If these two fields are within the same table, an auto-enter (Replace) calculation will take care of it for you - no script necessary. :wink2:

Try this as auto-enter (Replace) calculation on your B field. Be sure to uncheck in the calc box below 'Do not evaluate if all fields referenced are empty':

If ( not IsEmpty ( A ) ; not A )

LaRetta

Link to comment
Share on other sites

Hi LaRetta

oh actually it is suppose to be a checkbox, but checkbox not supported in iwp so i changed it to ask user to enter 1 or 0.

e.g. airticket: []Bookingrequired []Booking not required

therefore when user enter 1 in either box, the other box will generate 0 in it and vice versa.

Kelvin

Link to comment
Share on other sites

I should add here that, for this to work, you will need to stop Users from accessing field B as free-text. It should be validated as: B = 1 or not B

If you don't want them to change the field anyway, make it an indexed calculation instead. In this way, you won't have to protect the field from modification because you can't modify a calc. And you won't have to script it - it'll just consistently produce the correct result. Then all you will need to validate is field A.

But then again ... I don't know if I'm even answering the right question. When you said you had a simple calculation I hope you realize that doesn't mean your QUESTION has to be quick (see disclaimer below). In fact, the more you share to begin with, the faster we can help you. :wink2:

[color:gray]

Disclaimer: I am NOT a good model on how long a post should be. I tend to say too much, simply because I wish postees would say more. If I don't know enough about a situation then I start to feel like a call-in-for-advice talk show where they answer people's important questions without any proper background or direction. A dart board could do as well. :wink2:

LaRetta

Link to comment
Share on other sites

If [ Your_TO::a = 0 ]

Set Field [ Your_TO:: b; 1 ]

Else If [ Your_TO::a = 1 ]

Set Field [ Your_TO:: ; 0 ]

Else

Set Field [ Your_TO:: ; "" ]

End If

That's exactly what my last calc says, Lee. But I guess you could list it out if you wish. This one line just says your script a bit different:

Set Field [ B ; If ( not IsEmpty ( A ) ; not A ) ]

But I still think a simple radio is the best. Just click the radio and it'll toggle for you. What happens if they enter a 6? Or a G? Actually, you want A to be yes (1) if ANYTHING is entered, right? And field B to go empty? This is possible with Auto-Enter but I'm feeling a bit blind because I don't know what's possible in IWP.

L

Edited by Guest
Link to comment
Share on other sites

Hi LaRetta & Lee

Really thanks for all the help and advices.

I remembered wrongly, i thought that checkbox and radio buttons are not supported in iwp. I re-read my guide book again, it supports them but just that it don't maintain their columnar alignment.

Therefore i decided just use the checkbox buttons as like what LaRetta said what if they enter other stuffs and not my 1 & 0.

But when user choose 'A', can 'B' be greyed and if user choose 'B','A' be greyed which means it won't allows 2 fields to be checked. I am using 2 fields, field 'required' have 1 checkbox, field 'notrequired' have the other checkbox.

Thanks a lot yeah for the fast response~

Kelvin

Link to comment
Share on other sites

Hi Kelvin,

The purpose of value lists is to provide more than one method of selection for a SINGLE field. If a field is clicked 'Required' then it's not required. You don't need two fields. It is an on/off, true/false, yes/no, empty/not empty thing. If Required is empty - it's not required! This is why a radio button is perfect. When User clicks Required, the ONE field will fill with your Value List value (a 1 or required)! You can attach script to both buttons and make it more complex for yourself, but I just want to be sure you understand how simple this really should be. Truly, all you have to do is use ONE field (Required) and it'll do it all naturally. Well this is how I suggest you approach it, any way, but you would use a checkbox. :wink2:

If you STILL want two fields and a script then okay, here's one possible way (see attached). Be sure to turn off entry into checkbox or radio field (whichever you choose). I gave you both examples side-by-side. The yellow fields are just to show the actual data in the field(s). You will need TWO scripts (I believe) because you are addressing two separate fields independently using Set Field[] instead of letting the Value List simply set one field. Right below the example, I've take the liberty of showing you how easy it could be if you use only one field and let FM do what it does best. :wink2:

LaRetta

RadioCheckbox.zip

Link to comment
Share on other sites

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