May 1, 200520 yr Hi, can you help me I am creating a script that will be activated when a field specified as a button is clicked. When this script is performed, it makes use of the Get(ActiveFieldContents)function, by setting other (global) fields to the value of the clicked field, and finding records with criteria in the clicked field. However I cannot seem to get it to work. The first thing the script does is: (to prevent the script from continuing if the target field is empty) If(Get(ActiveFieldContents) = "" Show Custom Message "Please select a field" Exit Script End If And this always results in the message being displayed. Another test I have done is simply defining a calculation field as Get(ActiveFieldContents) and placing it in a layout I use for data entry. Selecting different fields in browse mode and entering data seems to have no effect, the field always stays blank. What am I doing wrong? Can Anybody guess why the Get(ActiveFieldContents) doesnt seem to work? Many Thanks Fred
May 1, 200520 yr Get(ActiveFieldContents) does work. However, it will not work for what you want. In your first example, if the field is defined as a button, clicking on it will activate the script, not the field. You could start the script by Go To Field [ thisField] to activate the field, but then you would have to specify the field by name, and I guess that would defeat your purpose. In your second example, when you click into the field, Get(ActiveFieldContents) gets the field's contents. But, for as long as your cursor remains in the field, the screen is not refreshed, so your calculation field remains empty. When you do click outside the field, the screen is refreshed - but at this time no field is active anymore. Try this to see how it works: - Define a global text field gActive - Add a button to the layout with the action: Set Field [ gActive ; Get(ActiveFieldContents) ] - Click inside any field, then click the button.
May 1, 200520 yr Author Can you suggest any way round the problem? What I have is a long list of global text fields, and on click one of these texts fields, or by other means, I want to be able to search for fields containing criteria defined by the text field clicked. I can do this one by one with individual scripts, but as I have over 50 fields this is tedious. I will continue fiddling...
May 1, 200520 yr Author OK, think I have sorted, Have the fields want defined as records in another file. Then that field set as value set in that file, then import value set into main file. Simple scripting from then on. One question though Is it possible for search criteria to be another field?
May 1, 200520 yr Some "status" (now "get") functions, such as Get (ActiveFieldContents) are not meant to be seen in Browse mode, only to be used in calculations and scripts. I guess because they can't evaluate in order to show. In the case where you're clicking on different fields, but want them to run a common script, I would use the new Script Parameter option, which you assign for each "button" attachment; it's at the bottom of the dialog. Just specify the field that it's attached to, and it will send the contents of that field. Use Get ( ScriptParameter ) to retrieve the value in your script. If [ IsEmpty ( Get ( ScriptParameter ) ) Show Custom Dialog [ "Field is Empty" ] Exit Script End If If you want to go to the field, in order to do a Find, or for any reason, you're going to have some problems. There is no Go To Field [ by calculated name ].* Further, by attaching a button to the field, it becomes impossible to get Active Field Contents or Name; because you're never actually in the field. And you can't Go To Field [ that field ] for this same reason. Catch 22 (old). It would be possible to set both the field AND its name (as hard-coded text) into the Script Parameter, as 2 separate lines, then parsing both out again (don't forget to remove the silly extra GoToField.zip
May 1, 200520 yr Hi to all I think that what I serched for isn't possible... It seems related to this topic. How can I retrive the name of a field, based on a string ? ( GetFieldName(text) ) So, if I have 2 fields: Field1="Apple", Field2="Banana" the result of GetFieldName("Apple") will be: Field1 :
May 1, 200520 yr Author Thankyou, using scriptparameter works brilliantly, although I still do need to set it manually for each field, it is still much much quicker.
May 1, 200520 yr If you look at my script you'll see that I hard-coded the field name into the script parameter. Then I had to Loop through the fields on the layout (where it is possible to Get (ActiveFieldName) ), until one of them matched (hopefully). That's the method, primitive but effective. You could do similar with Get (ActiveFieldContents), Looping though the fields, comparing the current field contents against a preset string value. If that's what you mean by "retrieve the name of a field based on a string"; do you mean "the name of the field who's contents are the string"? Tip: Commit Records/Requests removes the cursor from the Tab Order, then Go To Next Field will begin at the 1st field. You must trap so people do not get stuck in an endless Loop, if what is specified is not on the layout. I'm not at all sure what you're trying to do. I'm just guessing.
May 1, 200520 yr I believe you are on the right track. Here's a little demo showing how it might be done. findByPortal.fp7.zip
May 1, 200520 yr Well, comment's file is certainly more sensible, except for :-) "Our elephants enjoy daiquiri."
May 1, 200520 yr Hi, Fenton thank you for your quick replay You know that if I export a file as XML, there I can see the name of a field (of all the fields) and what is inside it... So I serched for a tip to grab that name, not its contents !(but based on its contents)
May 1, 200520 yr Author Please help me, see my topic in the Define Fields Forum, I think I may have to start my entire database again...
May 1, 200520 yr Hi, Michael I need the name of a field !! I can't use the normal functions of FM7, or so I think ! I need it for recursively search into a repeating field.
May 1, 200520 yr I still don't understand the context. How will you input the field contents? And what will you do with the name of the field, once you get it? IOW, I don't understand what is known and what not. Here's an example that does what you describe - but is it good for anything? GetFieldName.fp7.zip
May 2, 200520 yr Yes, you are right... I can't do anything with the name of a field in a script context. But I think that it's possible to use the name in a custom function... Your attachment does what I wanted, but you had to hard coded the names ! So, if I add a new Field5 with "ananas", and I search for ananas, nothing returns. (I would to add the Field5 !) In the case of a repeating field, I wish to have Field1[5] as the result !!
May 2, 200520 yr You shouldn't be chasing this: I need it for recursively search into a repeating field. Since it's not a proper filestructure, such searches went out of fashion in 1995 when filemaker became relational! Repeating fields is for relational keys not for storing data. --sd
May 2, 200520 yr I could have used the FieldNames() function - but then I would have to know the layout name. As I said - I don't know what the context is. It seems to me this is a solution looking for a problem.
May 2, 200520 yr Hi Yes, I know... But there are so many people who stored something into so much repeating fields that I wished a function to change a repeating field into a text field: GetRepeatition'sText(repeatingField), without using a Loop for each repeating field in a script.
May 2, 200520 yr Arghhh ! Yes, yes, yes !! It was that "Middle" that makes me a wrong finder ! Thanks for your effort ! Tip1 : Do you knew that you can obtain the MAXREPEAT of a repeating field with: GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField") ) ?? Tip2: Do you knew that You can set a "value list" with the values coming from a repeating field :
May 2, 200520 yr GetAsNumber ( FieldType ( Get ( FileName ) ; "repeatingField") ) It escapes me where to exploit such knowledge ...could you think up an example?? Drilling people in "nice to know's" serves what purpose exactly?? --sd
May 2, 200520 yr Hi, Soren I can't understand exactly what you said, but it seems to me that you are smiling back to me ?!! If it is so, never mind ! If it is not so, please help me to understand better what you said ! BTW the MiddleRepetitions ( repeatingField ; startRepetition ; endRepetition ) custom function by Comment requests (as I supposed) the endRepetition (or the MAXREPEAT, if you want all the values of the repeating field). This is a good example ?
May 3, 200520 yr My point is, why substitute one violation of 1NF with yet another violation? I'm guessing here - but isn't our task as developers to avoid inadequate methods by and large ...if you enherit a solution stuffed to it's burstingpoint with reperaters - must initial work establish what relational structure to pursue to prevent redundance and inconsitency. This means that only vanity prevents you from exploiting scripts to this once and for all task to transform data to fit into a new more reliably structure and wrongly stored information in it's proper place!!! The words for such devotion to repeating fields must be "Byzantine" and "Elaborate" ...and even worse "Stubbornness" ...alright they have their place as keyfield holders if Custom Functions are out of reach!!! --sd
May 3, 200520 yr I do not love "repeating fields". But we are forced to cohabit to them! As I have said to you, some solutions have been developed with this type of field and, in order to convert them with facility, I went trying one solution like that proposed by the friend Comment. After all, these words are not present in the English dictionary of babelfish: 1NF enherit burstingpoint inconsitency stubbornness alright
May 4, 200520 yr Ah yes, a few typos, I'm afraid: http://databases.about.com/cs/specificproducts/g/1nf.htm http://www.answers.com/inheritance&r=67 http://www.answers.com/bursting&r=67 http://www.answers.com/inconsistency&r=67 http://www.answers.com/stubbornness&r=67 http://www.answers.com/alright&r=67 Sorry! in order to convert them Why use calc'field in stead of scripted replaces? --sd
May 4, 200520 yr Alright ! finally I have understood to you. The use of the function is more simpler of the script (this is my opinion)! Many thanks for the link to www.answers.com ! Ciao
May 4, 200520 yr The use of the function is more simpler of the script Not sure: Loop Exit Loop If [ ValueCount ( Untitled::theRepeat[1] ) = 10 ] Set Field [ Untitled::theRepeat; Untitled::theRepeat & "
May 4, 200520 yr I think there may be more than one record... So it's two loops. And each record may contain a different amount of repetitions, so if you don't want to stack carriage returns it should be: Go to Record [ First ] Loop Loop Exit Loop If [ ValueCount ( Target ) = Count ( RepeatingSource ) ] Set Field [ Target ; Target & "
May 4, 200520 yr I agree with Comment. This is the last word for now... may be later...into other topics...
May 4, 200520 yr Hi, Comment You can't use Count(repeatingSource) !! It were be too simple !! You have to use the MAXREPEAT , as definited in other my post. I try to explain: I have a repeatingField of 7 repeatition, but one is empty. Monday Tuesday Thursday Friday Saturday Sunday Your solution gives: Monday Tuesday Thursday Friday Saturday That is wrong ! But: Replace Field Contents [ No dialog ; Target ; MiddleRepetitions ( RepeatingSource ; 1 ; GetAsNumber ( FieldType ( Get ( FileName ) ; "RepeatingSource") ) ] is always correct
May 4, 200520 yr Hmmm.. looks like I will have to fix that function to deal with empty repetitions. Never thought of that. Why would anyone have an empty repetition stuck in the middle? If it has any meaning, then perhaps the calc is correct in placing an empty value where the empty repetition is? In any case, if you have a repeating field defined with say 100 max repetitions, and you only use 10 of those on average, you'll end up with a stack of CR's, just like Soren.
May 4, 200520 yr You are right, as always In any case, if you have a repeating field defined with say 100 max repetitions, and you only use 10 of those on average, you'll end up with a stack of CR's This is another side effect that I (You ?) have to fix ! I wait for a new Middle...
May 5, 200520 yr But Michael The issue is here, that I can't get into my head why a calcfield is correct in a database with a wrong structure ...it's just a quick crappy remedy!! If repeaters are considered a need, should relations be introduced at once which calls out for export and re-import of data in the new structure... --sd
May 5, 200520 yr Hmm... You can still get the content of a repeating field from a value list as you said first, even in the order (with missing values) if needed with some work. I'm still not sure I understood what you're trying to do exactly.
May 5, 200520 yr Well, at least in this case the calc field is used to correct the wrong structure (if I understand correctly), so that can't be bad. I agree with you that import would usually be more efficient, but then I don't know all the circumstances. Actually I wrote the function for an entirely different purpose: repeating fields are fantastic calculators, but the result is stuck in the repetitions. To stretch a point, the only custom function you would ever need is MiddleRepetions(). Now you can do the "custom functions" in a repeater AND get the results in a regular field. And yes, Ugo, you can "drain" a repeater via a value list, but it is sloooowwwww... I see a lot more use for repeating fields than you seem to. Now that Ugo has shown us the speed method for creating records via import w/split repeating, I can even see situations where ACTUAL DATA could be kept in repeating fields, and reports created on the fly by importing (and then discarded). And more... Finally, if someone wants to use repeating fields inapropriately, I believe that is their business. As long as it works for them, why should I get angry. It's not a moral issue. BTW, I use repeaters to store data myself in one of my own files. This data will never be searched, reported or summarized. So I do "the forbidden thing", fully aware of the price to pay if I am ever proved wrong.
May 5, 200520 yr Now that Ugo has shown us the speed method for creating records via import w/split repeating Well I used to do so as well, but the stuff I do at present is via IWP s
Create an account or sign in to comment