Jump to content

Only Be Able to Edit a Field if Another Field = Value List


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

Recommended Posts

Hello!

I'm trying to make field2 only editable if field1's contents match valuelistA.

Otherwise, it won't allow editing of field field2's contents.

(Ohhh the things we do to protect our data from lazy people!)

Any ideas?

Thanks!

Link to comment
Share on other sites

I am afraid that is not a good test. If valuelistA =

one

two

three

"ne", "e", "wo", "o" pass the test. "three" does not.

The test should check the occurence of ¶ & Field & ¶ in ¶ & ValueListItems(...) & ¶.

Since a single occurence is enough to pass to test, there's no need to continue counting beyond the first occurence. The Position() function will be more efficient here:

Position ( ¶ & ValueListItems ( Get(FileName) ; "yourValueList" ) & ¶ ; ¶ & yourField & ¶ ; 1 ; 1 )

Note that the condition > 0 is redundant in a logical test.

Another option:

not IsEmpty ( FilterValues ( yourField ; ValueListItems ( Get(FileName) ; "yourValueList" ) ) )

I would also not use validation for this. Validation does not make a field ineditable. It allows to user to edit, then tells him he shouldn't have messed with it in the first place.

A better solution, I think, would be to make the field non-enterable, and format it as a button that runs a script:

If [some condition is true]

Go to Field

End If[]

Link to comment
Share on other sites

Note that the condition > 0 is redundant in a logical test.

No matter how many times you have pointed this out, I still fall back on habit...

"ne", "e", "wo", "o" pass the test. "three" does not.

Yep, that was the poor mans validation calc. However, I believe FM puts a carriage return at the end of the last item on a VL, so I think "three" does pass the test.

On the topic of streamlining calcs, am I correct in thinking that your position calc would be more efficient than your filter calc?

-Raz

Link to comment
Share on other sites

I believe FM puts a carriage return at the end of the last item on a VL

I don't think so. I believe you're confusing ValueListItems() with the LeftValues(), MiddleValues() RightValues() and FilterValues() functions that do this.

am I correct in thinking that your position calc would be more efficient than your filter calc?

I am not sure. I understand why you'd think so, but I don't know the algorithm behind FilterValues(), and I haven't done any comparison tests.

Link to comment
Share on other sites

I believe you're confusing ValueListItems() with the LeftValues(), MiddleValues() RightValues() and FilterValues() functions that do this.

No, I was remembering something I was playing around with a few days ago. I was using my poor mans calc on a demo with reasonable results. I will look it up, but am sure you are correct.

Have you tested all the other functions (Position, Pattern count, etc), or is there an algorithm chart for FM somewhere? I am working on a massive calc that could benefit from as much streamlining as possible...

Link to comment
Share on other sites

Why guess, when it only takes a minute or two to verify...

I haven't actually tested Position() vs. PatternCount(), but I think it's pretty obvious that PatternCount() is just multiple occurences of Position() - that's why you need to specify the occurence parameter in Position(). Certainly, finding the n-th occurence takes more and more time as n gets higher - until you reach the same efficiency as PatternCount().

Link to comment
Share on other sites

Well, its really the "etc" I'm concerned about here - more generally, the algorithmic guts behind all the functions. The manual is pretty sparse on this, telling you what they return, but not necessarily how they return it (or when they do tell you how, it is not clear if it is actually ‘how’ as opposed to an abstraction that is easier for us to read). While it may only takes a minute or two to verify two functions against each other, the n! combinations of the various ways to approach any given task makes that a bit daunting, and if this has been done before somewhere, it would be great to have that baseline to compare results with.

For your testing purposes, do you use script steps setting a timestamp before and after? Are you looking at the activity monitor as well? Is there a standardized method to pit two calcs against each other?

-Raz

Link to comment
Share on other sites

This topic is 5732 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
 Share

×
×
  • Create New...

Important Information

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