Jump to content

Case does not return what I expect

Recommended Posts

Hello, I have a Case calculation that does not return what I expect

wd1 = width of image in container1 , ht1 = height of image in container1

wd2 = width of image in container2 , ht2 = height of image in container2

A script would open up a popup window sized to the parameters of the image in the container. This is how it starts:

Set Variable [ $contfield; Value:Get ( ScriptParameter ) ]  //which is the name of container1 or 2 which it gets correctly

Set Variable [ $ht; Value:Case (
$contfield = Untitled::container1; Untitled::ht1; 
$contfield = Untitled::container2; Untitled::ht2; 
"ERROR") ]

Set Variable [ $wd; Value:Case (
$contfield = Untitled::container1; Untitled::wd1; 
$contfield = Untitled::container2; Untitled::wd2; 
"ERROR") ] 

The calculations return "ERROR". Which I don't understand as I would expect $ht/wd to be set to the corresponding numbers in ht1/2 and wd1/2. What am I doing wrong?


Share this post

Link to post
Share on other sites

so $contfield resolves to Untitled::container1, not just container1? How is the script parameter set?

And you may need quotes to match literal text, rather than whatever the value of the field is...

And why not just pass the width and height in the script parameter in the first place?

Edited by webko

Share this post

Link to post
Share on other sites

Script parameter set by specifying Optional Script Parameter as GetFieldName ( Untitled::container1 )  or 2 depending on the field clicked. Yes, it resolves to Untitled::container1/2. And this is a simple test file with one table.

I am not sure how to set two different script parameters with one step. 

Share this post

Link to post
Share on other sites

The test:

$contfield = Untitled::container1

will return true only when the contents of the variable match the contents of the field - in your example, that would be true only if the container field contained the text "Untitled::container1". To test that the variable contains the name of the field, you need to do:

$contfield = "Untitled::container1"

or preferably (so that you can change the field's name without breaking the calculation):

$contfield = GetFieldName ( Untitled::container1 )


There's probably a shorter way to get what you want. How are the fields wd1, ht1, wd2 and ht2 populated?

Share this post

Link to post
Share on other sites

$contfield will be different depending on which field will activate the script, thence the need for a script parameter. 

wd/ht are calculations: GetContainerAttribute ( container1 ; "width" ) etc. I'm sure this could be tighter but this is just a test file.


I tried adding explicit "-s to the FieldName but it still does not work

Share this post

Link to post
Share on other sites
2 hours ago, Asu said:

I tried adding explicit "-s to the FieldName but it still does not work

If the script parameter is set to be =

GetFieldName ( Untitled::container1 )

then it contains the string "Untitled::container1". If you're seeing something else, then there something you're not telling us.


2 hours ago, Asu said:

wd/ht are calculations: GetContainerAttribute ( container1 ; "width" ) etc.

If the only purpose of the fields is to serve this script, then you could eliminate them. The parameter could be simply either 1 or 2, and then your script could just open a new window and calculate its height as =

GetContainerAttribute (
Case (
Get (ScriptParameter) = 1 ; YourTable::Container1 ;
Get (ScriptParameter) = 2 ; YourTable::Container2
) ;
"height" )

and a similar calculation for the width.

In fact, with only two fields, I would make the buttons perform the New Window step directly and specify the field explicitly.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By docasar
      I am still very amateur on Filemaker so i hope my question does make any sense.
      I am trying to write a script that would basically import order information from an email and convert it, first in a new account (if the customer does not exist) and later create a Sale Order. So far, I have managed to do that, but the problem i find is when trying to convert the sale order into an invoice. Since this order comes from our webshop when we receive the email means it is paid, so my aim is that when creating the invoice from the Sale order, this would be marked as paid and set the amount due to zero.
      This would sound a very easy task, but since our solution incorporates a payments module to manage the payment of an invoice, when i try to incorporate the payment entry within my script, there is when all the trouble starts. For some reason, it gets lost in its way when runnig the script and returns a partial payment all the time. The weirdest thing is thet if I run the script on debug mode, then all works perfectly, so my guess is that the issue may be related to the speed of the script.
      So, is there any recomendation as for where to put a pause script step so the script will work also when run automatically?
      I have tried every possible combination of long script, shorter with other scripts inside, perform script on server... and all the time something is wrong ;(
      Thanks a lot for any insight thst would help us move forward, since we have been trying to solve this for a week already.
    • By Richmilnix
      For an inventory management database, I'd like my main screen to be able to accept pulls from three related databases:
      - Serialized (valuable tools, which I track and want back - the paintbrush);
      - Replenishable (cheap tools that I buy by the yard and if one gets left behind I don't care - the paint-mix sticks);
      - Perishable  (disposable tools that are left on the job site - the paint).
      These will handle their related requests differently. The serialized I'll be tracking properly to make sure we keep track; the latter two I'm looking for more like a system of 'tick marks' to help me know what we use on job sites.
      We print our barcodes. For ease of use, I'd like staff to scan into a single field in an interface that is smart enough to do the right thing based on a key digit in the barcode. So when I scan barcode 'S1234', my db knows to move it to the Serialized relation field; when I scan 'P1234,' it knows we're in Perishables.
      Looking for the elegant approach. My thought is that that central hot field (Scan_Here) will, when entered, store a variable and trigger a script built within the context of the related table, but I'm sometimes prone to reinventing wheels and doing stuff the long way, so I'm asking for suggestions / examples.
    • By JH Howland
      I have created an "opener" file called "OpenMP" that is located on the Windows Desktop.  Also, a global variable for the directory where the FMP14 files are located called "$$marinaDir" = "MarinaPro v17".
      When activated the launcher opens but does not open the target file using the following file path, "filewin:/C:/$$marinaDir/Marina.fmp12."  However if I substitute with the following, "filewin:/C:/MarinaPro v17/Marina.fmp12"; all is good.
      The script elements follow:
      #Create variable...
      Set Variable [$$marinaDir; Value: "MarinaPro v17"]
      #Start MarinaPro...
      Open File ["Marina"] (Marina File Path: filewin:/C:/$$marinaDir/Marina.fmp12)
      What am I missing?
    • By Jim Gill
      I'm have an issue sending emails via SMTP Server using a calculation field in the "To:" field.  When I use the calc my outgoing emails are filtered as spam by the hosting service.   If I put the Email Field in the SMTP To:  emails are sent successfully.
      Here is the setup:  
      I have a Parent Table with the fields Email_Parent1, Email_Parent2, Email_Parent3 and a related SuperParent_Email.
      Parents can opt-out/in of mailings by selecting flag_P{1-3}_Mailings.
      I'm trying to to get the field Email_List output to look like this:
      Email_Parent1@mydomain.com; Email_Parent2@mydomain.com; Email_Parent3@mydomain.com; SuperParent_Email@mydomain.com alternatively if a record is missing an email:
      Email_Parent1@mydomain.com; Email_Parent2@mydomain.com What I'm getting is this:
      P1Email@gmail.com; P2Email@hotmail.com;  Note the semicolon at the end Here is what I have for a calculation for the field Email_List 
      Case ( flag_P1_Mailings=1; 
        If ( IsValid (Email_Parent1);Email_Parent1 & 
        If ( IsValid (Email_Parent2);"; ";"")));
      Case ( flag_P2_Mailings=1; 
        If ( IsValid (Email_Parent2);Email_Parent2 & 
        If ( IsValid (Email_Parent3);"; ";"")));
      Case ( flag_P3_Mailings=1; 
        If ( IsValid (Email_Parent3);Email_Parent3 &
        If ( IsValid (__ParentData_SuperParent::SuperParent_Email);"; ";"")));
      Case ( IsValid (__ParentData_SuperParent::SuperParent_Email);__ParentData_SuperParent::SuperParent_Email;"")
      Can someone help me clean this up please?  
      Thanks so much!
    • By davidrichards
      I am having a tough time getting the set field by name script step to work and hoping someone can help me with this.
      I have a file of sales transactions over many years.  I have a related file for customers.  The customer file has counters for how many times a customer visits each year, how many suits, sportcoats, etc. they buy each year ( visits_2017, visits_2016, visits_2015, suit_count_2017, suit_count_2016, suit_count_2015 and so forth). I would like my script to evaluate the year of the transaction in sales and update the appropriate counter in customers.
      I have been unsuccessful in defining a variable and set field by name combination to accomplish this task.  Any recommendations?
  • Who Viewed the Topic

  • Create New...

Important Information

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