Asu Posted January 22, 2017 Posted January 22, 2017 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
webko Posted January 22, 2017 Posted January 22, 2017 (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 January 23, 2017 by webko
Asu Posted January 23, 2017 Author Posted January 23, 2017 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.
comment Posted January 23, 2017 Posted January 23, 2017 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?
Asu Posted January 26, 2017 Author Posted January 26, 2017 $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
comment Posted January 26, 2017 Posted January 26, 2017 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.
Recommended Posts
This topic is 3124 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