Kingme Posted March 16, 2007 Posted March 16, 2007 I'm looking for a way to see what the user just searched for. Currently I have a layout with about 10 fields in it that can be searched. I would like to find out what the user actually searched for, to then show them on the "results" layout "Your search for 'X' came up with the following results." I could probably just loop through the fields on the layout with isEmpty then perform the find but I was wondering if anyone has a better idea. (what if the fields change.. I would have to go back into the script and change the loop to now look at the "new" field and delete the old ones.) I know filemaker "stores" the find.. for use in "modify last find" but I can't seem to easily "see" this information.
Genx Posted March 16, 2007 Posted March 16, 2007 ... The only way to do this is scriptually i.e. Allow User Abort[Off] Set Error Capture[On] - Enter Find Mode[Pause] Set Variable[ $fieldsSearched ; If( not IsEmpty(field1) ; "Field 1: " & Field1 & ", ") & If( not IsEmpty(field2) ; "Field 2: " & Field2 & ", ") & If( not IsEmpty(field3) ; "Field 3: " & Field3 & ", ") & . . . If( not IsEmpty(field10) ; "Field 10: " & Field10 & ", ") ] Perform Find[] Show Custom Dialog[ "Search Results" ; "your search for " & $fieldsSearched & " returned " & Get(FoundCount) & " results." ]
Lee Smith Posted March 16, 2007 Posted March 16, 2007 If you just want to see the last find, then hit Command R, and it reinstates it. However, I think what you are wanting is more indept than that. If so, then you should consider scripting the eitire find process as Genx has suggested. There are a couple of demostation (how to) files availabe to show a couple of methods. Here is one that has a video and a file: Link Lee
Kingme Posted March 16, 2007 Author Posted March 16, 2007 Thanks for the help. I figured i'd have to use the "isEmpty" deal-o and script it all. I change "search fields" very often on that layout of 10 so I was hoping for an "automagic" way to see the search instead of having to go into the scriptmaker and change the "isEmpty" fields so often. Thanks for the help and the links!
Genx Posted March 16, 2007 Posted March 16, 2007 ... well, technically... you could loop through all the fields on the layout as such: Freeze Window Go To Field[ field1 ] Loop Set Variable[ $fieldsSearched ; $fieldsSearched & If( not IsEmpty(Get(ActiveFieldContents)) ; Get(ActiveFieldName) & ": " & Get(ActiveFieldContents) & ", ") ] Exit Loop If[ Get(ActiveFieldName) = "field10" ] Go To Next Field End Loop field1 is your first field, and field10 is the last field on your layout in the tab order
comment Posted March 16, 2007 Posted March 16, 2007 Technically, this can be completely dynamic, without hard-coding either field names or the number of fields on the layout, e.g. Go to Field [ ] Go to Next Field Set Variable [ $firstFieldName; Value:Get ( ActiveFieldName ) ] Loop Set Variable [ $criteria; Value:$criteria & Case ( not IsEmpty ( Get ( ActiveFieldContents ) ) ; Get ( ActiveFieldName ) & ": " & Get ( ActiveFieldContents ) & ¶ ) ] Go to Next Field Exit Loop If [ Get ( ActiveFieldName ) = $firstFieldName ] End Loop Go to Field [ ]
Genx Posted March 16, 2007 Posted March 16, 2007 (edited) Cool On a serious note though, my stupidity and your anti-stupidity (aka smart-ness) scare me sometimes lol. Edited March 16, 2007 by Guest
Lee Smith Posted March 16, 2007 Posted March 16, 2007 Hi Genx, You are not stupid! In fact, I've always been impressed with your abilities, knowledge, etc. I feel like a neebee here though. Could someone please make an example file, or explain in some detail, how this script solves the problem of providing a history of the Finds that were done by the User? TIA Lee
Genx Posted March 16, 2007 Posted March 16, 2007 Well, it doesn't really provide a history, just shows what criteria the user used in their last find... which as far as i understand given the comment below is what the op wanted: I could probably just loop through the fields on the layout with isEmpty then perform the find but I was wondering if anyone has a better idea. (what if the fields change.. I would have to go back into the script and change the loop to now look at the "new" field and delete the old ones.) Small file attached, and thanks for the reassurance Logic just seems to elude me sometimes though. example.zip
comment Posted March 16, 2007 Posted March 16, 2007 Hey, no personal remarks, please. (But if I thought you were stupid, I wouldn't bother.)
Lee Smith Posted March 17, 2007 Posted March 17, 2007 Thanks Genx, nice job. Now I see what I was doing wrong. At least I think so. I'll look deeper tomorrow. Lee
Recommended Posts
This topic is 6518 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