Mike13a Posted April 11, 2008 Posted April 11, 2008 I am trying to use GetasBoolean in a calculation where I am using a global repeating field. The fields are used in report generation and I need to test to make sure only one field has data in it or less. Repetition 7 has text, all others have numbers. All but Repetition 7 give me a response when I enter something into them....the calculation is below: It is supposed to recognize text and give me a 1 for the statement, but it does not. Let ([ A=GetAsBoolean ( gReport Field[1] ); B=GetAsBoolean ( gReport Field[2] ); C=GetAsBoolean ( gReport Field[3] ); D=GetAsBoolean ( gReport Field[4] ); E=GetAsBoolean ( gReport Field[5] ); F=GetAsBoolean ( gReport Field[6] ); G=GetAsBoolean ( gReport Field[7] ) ]; Case(A=1;1;B=1;2;C=1;3;D=1;4;E=1;5;F=1;6;G=1;7;"") ) Any help would be appreciated. Thanks, Mike
comment Posted April 11, 2008 Posted April 11, 2008 (edited) I am trying to use GetasBoolean ... It is supposed to recognize text and give me a 1 for the statement I am afraid you are mistaken there - GetAsBoolean does NOT "recognize text". The help on the function may be a little misleading. GetAsBoolean ( "Some text here" ) returns 0, while GetAsBoolean ( "Some number here 123" ) returns 1. Perhaps you want to use the IsEmpty() function - I am not too sure what exactly you are trying to achieve. --- P.S. Please update your profile - there's no GetAsBoolean() in version 5. Edited April 11, 2008 by Guest
Mike13a Posted April 11, 2008 Author Posted April 11, 2008 2 things: 1 Quoted directly out of the "Filemaker 8 Functions and Scripts" book: GetasBoolean(data) date = Any text, number, date, timestamp....etc This is what I was going by when I designed this calculation. 2. I thought I did update my profile to show 9 advanced and Tiger. I didn't realize it didn't take. thanks for pointing it out. (or chastising?) Mike
comment Posted April 11, 2008 Posted April 11, 2008 In defense of the book authors: the parameter of GetAsBoolean() CAN be any one of the mentioned types. That has nothing to do with what the function DOES with the data passed to it by the parameter. Knowing your version helps us in deciding what might work for you, and esp. what will not.
Mike13a Posted April 11, 2008 Author Posted April 11, 2008 So how am I supposed to understand the function when using the book if they are giving me cryptic or incorrect answers? It clearly states "Returns a 1 if the expression or data pased into the function is not zero or empty." I interpret that as putting text in there should result in a 1.... Since I don't use the forums site on too regular a basis, I didn't realize that selecting my profile data from the pulldowns below this box I am typing into doesn't update my profile? I had entered my data as 9 Advanced on Tiger, using 8 Server on Tiger. Do you recommend a different book for understanding Calculations and scripts?
comment Posted April 11, 2008 Posted April 11, 2008 I didn't write that book... Usually, I find it best to refer to the description of the function in the application's help. This states: "Returns 0 if data has a value of 0 or is empty, all other values return 1." This is essentially correct, even if it's not a very good explanation (and as I stated earlier, the subsequent examples can be misleading). Note that "returns 0 if data ... is empty" does NOT necessarily mean it always returns 1 when data is not empty, as your quote from the book seems to imply.
comment Posted April 11, 2008 Posted April 11, 2008 (edited) To update your permanent profile (as shown in the sidebar), go to My Profile > Control Panel. The "FileMaker Profile" you see when replying applies to the posted message only - allowing you to make an exception. And you need to check the "Show..." box. --- Testing --- Edited April 11, 2008 by Guest
David Jondreau Posted April 11, 2008 Posted April 11, 2008 (edited) No post in this thread so far has shown a separate set of details regarding application and platform version. Testing... Ah, there we go. Edit 2: When editing your post, you've got to "re check" Show Filemaker Profile. I assume the OP missed that check box to begin with. Edited April 11, 2008 by Guest
Søren Dyhr Posted April 11, 2008 Posted April 11, 2008 There is something wrong here, you seems to wish for a command telling you the first available repetition, you're mistaken by the working of the case statement ...which goes like this there will only be evaluated branches of a statement until a positive result is reached, the remaining are left unevaluated of speed reasons. This is a deviation from the workings of fm5 which followed the OPN standart. What you might be after is this: http://www.briandunning.com/cf/472 I do however frankly not have one single purpose I would throw this after since the functionality much much better is obtained via: http://www.filemaker.com/help/Script-Steps20.html ...in a normalized structure! Please justify your toying with repeaters??? --sd
comment Posted April 11, 2008 Posted April 11, 2008 there will only be evaluated branches of a statement until a positive result is reached, the remaining are left unevaluated of speed reasons. This is a deviation from the workings of fm5 But the returned result is the same.
Mike13a Posted April 12, 2008 Author Posted April 12, 2008 reply to Seren: you are misunderstanding what I am trying to accomplish. And is it necessary to chastise me merely because I have only posted on this forum a handful of times? (...in a normalized structure! Please justify your toying with repeaters???) I am using a global repeating field for entry on a page that is used to generate a report. What my Let function does is only allow one global repetition(or less) to contain data, regardless of which order it is selected. If two repetitions have data in them, it will place a red X into the container field, if only one, it will place a green checkbox, indicating the user may proceed with running the report. There is also a button hidden by a portal that only shows when all 3 sections of the report page have the green checkboxes, indicating that the user made valid choices that will return correct information when the report is run. It is quickly visual, and made it so I didn't need to test for several different errors of data entry at the beginning of the report script. I merely wanted to know why the GetasBoolean wasn't giving me the result I expected when reading the description given to me in the scripting book I referenced in an earlier post. So it appears I will need to change the Let statement to contain not IsEmpty(gReportfield[x]for each repetition. I just thought the getasboolean was cleaner....Oh well! Thanks for everyone's assistance (and admonishment) I have since modified my profile to show that I am using 9 Advanced, with Server 8, and that I am a fairly accomplished developer. I apologize if I confused some posters who thought I was on FM 5 and an older version of OSX, I don't use the forums much and didn't update my profile properly. I saw the section below where I post and entered my current info there, thinking it would update my profile. I understand we are all passionate about Filemaker and willing to help, so I understand your desire to steer me clear of repeating fields. The database contains several fields in that particular table and having 1 global field with 7 repetitions was cleaner than adding 7 global fields. Plus it allows me to reuse those global fields for all my report generation choices.
comment Posted April 12, 2008 Posted April 12, 2008 What my Let function does is only allow one global repetition(or less) to contain data, regardless of which order it is selected. I don't quite see how it does that. If the first repetition is not empty, the returned result is 1 - regardless of how many OTHER repetitions may be filled. I'd think that: Count ( gReport Field ) ≤ 1 would be the correct test to use here.
Mike13a Posted April 12, 2008 Author Posted April 12, 2008 Sorry, I posted the wrong Let function! I actually have two calculations using similar functions. the one displayed in my first post is the one that tells the script which repetiton contains the data to pass to the correct field for the find. The other Let function starts similarly, but then has a Test = A+B+C+D+E+F+G followed by a case( Test<2, global container[1];global container[2]) Now I understand the confusion and the help everyone was offering in previous posts! Sorry to confuse everyone.....I am running on about 4 hours sleep last night and 4 hours the night before, so I am a little off today. Thank god it's Friday! I think I've had enough Filemaker for today. Time to go have a cold beverage and watch some hockey.
Søren Dyhr Posted April 12, 2008 Posted April 12, 2008 http://www.filemaker.com/help/FunctionsRef-33.html ...comes to mind here! Michael have already aired the virtues of Count( which even could be put inside the bracket of you repeater, but Choose( handles numbers via an invisible Int( inside! --sd
Søren Dyhr Posted April 12, 2008 Posted April 12, 2008 You're right there are only integers involved! BTW do I lack your comment to this: http://fmforums.com/forum/showpost.php?post/287454/ Are there flaws here as well?? --sd
Søren Dyhr Posted April 12, 2008 Posted April 12, 2008 Two questions why not use wingding or webding chars for this?: If two repetitions have data in them, it will place a red X into the container field, if only one, it will place a green checkbox, indicating the user may proceed with running the report. I'm not absolutely clear why it's done this way: I am using a global repeating field for entry on a page that is used to generate a report. Why not individual globals over each column, plucking the right fields value via: Evaluate( or GetField( But perhaps is the question here to omit unused colomn?: http://www.fmforums.com/forum/showtopic.php?tid/191492/tp/0/all/1/ --sd
comment Posted April 12, 2008 Posted April 12, 2008 LOL, how can I be right - I only asked a question. I am still puzzled at the method chosen for data entry, though. It seems users are required to supply a value (by entering it into ONE of the repetitions) and a category (by choosing which repetition they enter the value into). I believe it would be a lot easier for both users and developer to enter the data into TWO separate fields: one for value, and another for category (e.g. radio buttons).
Mike13a Posted April 12, 2008 Author Posted April 12, 2008 Good morning Michael and Soren, Well, It seems you are both confused as to what is happenng. Maybe a little more background. System is used for tracking bilings in an in-house creative services agency. Clients, jobs, groups, project managers, timecards,vendors, etc. It is probably 20 tables right now, with a relationship graph that spans 25 - 30 pages. The report screen lets them run a report on jobs billed over a time period. the repeating fields come into play to alow them to narrow the results. For example, show me only jobs for client x, or vendor, y or project manager z, etc....These are chosen by pulldown menus in the repeating fields. I am only allowing them the ability to narrow it down by one choice only at the curent time. I suppose I could have used the wingding or webdings, I just hadn't thought about it at the time. And the container fields work just as well for what need. Once the user makes a date choice, and a sort choice they are then presented with the button in the portal to run the report. I chose to use a repeating global field vs 7 separate global fields merely to have less fields in that table. It is not harming the function or form in any way that I know of. I certainly would not use them elsewhere.....I was trying to attach a screen capture to show you what it looks like, but it never seems to finish attaching.....I may try again later.
ralph.nusser Posted April 25, 2008 Posted April 25, 2008 (edited) You are right. [color:green]GetAsBoolean works not as expected. Please, answer the following questions before you download the example file. Description: Returns zero if data has a value of "0" or is empty, all other values return 1. Parameter: data - any text, number, date, time, timestamp or container expression, or a field containing text, a number, date, time, timestamp or container. Do you get a [color:red]1 or a [color:blue]"0" with [color:green]GetAsBoolean: 1. Zero in number field? 2. Zero in a date field? 3. Zero in a container field? 4. "George Orwell, 1984" in a text field? 5. "George Orwell, ninteen eighty-four" in a text field? 6. In a time field the time is given one second before midnight. A script adds one second? 7. In a time field the time is given one second after midnight. A script deducts one second? Who did give the right answers to all seven questions? Happy FileMaking Ralph Nusser Sogetes Computer-Services www.sogetes.com GetAsBoolean_SOGETES_1_0_1.zip Edited April 25, 2008 by Guest
comment Posted April 25, 2008 Posted April 25, 2008 Oh, a puzzle? Let's see: 1. Zero in number field? 0. 2. Zero in a date field? Normally, it's not possible to enter zero in a date field, but if you managed, then GetAsBoolean will return 0. 3. Zero in a container field? 1 (any data in a container field returns true) 4. "George Orwell, 1984" in a text field? 1 5. "George Orwell, ninteen eighty-four" in a text field? 0 6. In a time field the time is given one second before midnight. A script adds one second? 1 (Time is now 24 hours) 7. In a time field the time is given one second after midnight. A script deducts one second? 0 (assuming the time was 0:00:01, not 24:00:01) Where GetAsBoolean does NOT return the expected result is when you have a question mark in a text/number field. Other then that, it's all as expected, I think.
Recommended Posts
This topic is 6116 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