Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 2857 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

Thanks

Posted (edited)

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
Posted

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. 

Posted

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?

Posted

$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

Posted
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.

This topic is 2857 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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