js22 Posted April 18, 2007 Posted April 18, 2007 Hello, Why would a working script stop working? I have a script that does a find that used to work in my database and now it doesn't. I have narrowed down the problem to a validation that is in place. How it is set up: I have a value list based off of a field (SampleID) This field is a serialized number that is non-repeating. Here is my script: Enter Find Mode [] Show Custom Dialog ["Enter Sample ID of Interest" ; Samples::SampleID] Here is where the problem exists If [not Position ( ¶ & ValueListItems ( Get ( FileName ) ; "Sample IDs" ) & ¶ ; ¶ & Samples::SampleID & ¶ ; 1; 1)] Show Custom Dialog ["Invalid Sample ID"] Enter Browse Mode [] Halt script Else Perform Find [] If [not Get (FoundCount)] Show Custom Dialog ["No records found."] Show All records Halt Script End If End If Somehow it does not validate with the not Position [] function. The wierd thing is that it used to work. I have no idea why it would quit working. Does anyone have any ideas? Also I had help with the script and I was wondering what the function of the ¶ and the & is. I just am wondering what they do and when to use them. thanks js22
Søren Dyhr Posted April 18, 2007 Posted April 18, 2007 Un-tie the dependency of a valuelist, by using List( instead. But there must be a specific reasoning for not using the native either unique or "member of list" validation?? Secondly simplify the readbility by using: http://www.filemaker.com/help/FunctionsRef-369.html Finally should you justify the use of the Halt statement in the end of the script??? --sd
Genx Posted April 19, 2007 Posted April 19, 2007 (edited) FileMaker validation is ugly and barley makes sense to me so i wouldn't expect it to make sense to the end user. In relation to your question ¶ and the & is. I just am wondering what they do and when to use them. ¶ - A Pilcrow -- i.e. a carriage return & - Ampersand -- used to concatenate expressions i.e. "I think, ¶" & "therefore I am" will return: I think, therefore I am In this case, you are using it because you need to check for an entire pattern.. your value list when returned from your original ValueListItems() expression looks like this: I¶am¶a¶coolvaluelist ¶ & I¶am¶a¶coolvaluelist & ¶ returns: ¶I¶am¶a¶coolvaluelist¶ -- you'll notice that every value now starts with a pilcrow and ends with a pilcrow, that is every value now has the form ¶value¶ and pilcrow essentially acts as a value delimitter. Now - if you have the value "value" and you are looking for it in the list above - if you were just to use Position( ValueListItems() ; "value") this would return true, because "value" actually exists above -- inbetween cool and lists -- even though it's not an item in-itself, it is present in some other item -- so you have to use some form to be able to isolate individual items... In this case it's just easiest to use pilcrow because that's how FileMaker returns the value list items to your calculation Now, originally the first and the last values wouldn't have been picked up properly -- i.e. Position( I¶am¶a¶coolvaluelist ; "¶coolvaluelist¶" ) will return 0 because ¶coolvaluelist¶ doesn't exist anywhere... only ¶coolvaluelist exists But when we change the above to be Position( ¶I¶am¶a¶coolvaluelist¶ ; "¶coolvaluelist¶" ) -- then that will return a value greater than 0. Confusing I know, but that is probably because i'm not great at explaining, but i hope you get the jist. Edited April 19, 2007 by Guest
js22 Posted April 19, 2007 Author Posted April 19, 2007 Thanks for the replies. The help and explanation were very insightful. I have changed the way that they find works and I have run into a new dilemma now that I've changed the code a little. The new setup is no longer based on a dialog box. I have a table called Globals and there is a field named "Find" that is set as a global field. So on the layout there is a field for Globals::Find. The user enters the sampleID they want to find in that field and then click a button right below it with this code: Set Variable [$PatternCnt; Value: PatternCount (Globals::Find ; Samples::SampleID)] If [$PatternCnt < 1] Show Custom Dialog ["Find Samples"; "Pattern Count = " & $PatternCnt & ¶ & "Try Again. Record Not Found"] Else Enter Find Mode [] Insert Calculated Result [select; Samples::SampleID; Globals::Find] Perform Fin [] Set Field [Globals::Find; ""] End If Enter Browse Mode [] Show All Records It isn't validating though when it should. Any help would be very nice. I've attached a template to show what I can't explain very well. My main reason for the validation is to simplify it for the end user so they don't get stuck in find mode and can't find their way out. This is the most simple idea I could come up with. If anyone else has an idea that would be great. Thanks js22 Find_with_Globals.fp7.zip
js22 Posted April 20, 2007 Author Posted April 20, 2007 Thanks, that is exactly what I'm looking for. js22
Recommended Posts
This topic is 6429 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 accountSign in
Already have an account? Sign in here.
Sign In Now