Jump to content
Monarch

Script Parameter in conditional formating and color changing

Recommended Posts

I want to create an image of the clock, with round dial, numbers as buttons (from 1 to 12, maybe even half an hour numbers). So here is the challenge (for me...):

1. Each button changes color on a corresponding slice of the clock, if you click once - white, click again - original color and so on back and forth between those two colors... Multiple colors would be nice too.

2. Using two buttons to select a chunk/slice of the dial, for example click on 12 and 4 will turn slice between 12 and 4 numbers into white color automatically without clicking on each number in between.

OK, changing colors - conditional formatting - easy. Using one script for doing it - script parameter - easy.

But then I can't get my mind around the rest of the puzzle. Here are my questions:

a. How to keep selected color (it changes if I click different number), without going into using complex calculations and multiple fields.

b. For my second problem (creating a slice) - I don't even know how to approach it...

c. Also simple question: what is better to use as buttons in this case - field, object, or smth else?

There must be a much more efficient and elegant way to do it. My guess is - variables, but I m getting lost with them.

Any help please...

 

 

Share this post


Link to post
Share on other sites

Hi Monarch, would you explain the purpose of this?  Is it so a User can select a time which must be stored in the table?  Is it for the developer to provide the User with feedback of some sort?  Knowing what you wish to do with this information will help us determine what to provide.  :-)

Share this post


Link to post
Share on other sites

I think you have more than one question here. Before getting into any one of them, I would ask how do you plan to handle AM vs. PM with only 12 buttons to select from.

Share this post


Link to post
Share on other sites

Yeah... AM/PM  is also a question.

This is for a schedule program which I am trying to create. I like visual stuff, so I thought it would be nice to have a clock like that.

The idea is to select a "slice" of time and then transfer it to a table for each active row in the portal. I hope I explained it clear...

It sounded simple to me at first. But if it s getting too much - I might have to drop the whole idea :( and just stick with "boring" text and numbers.

And thank you guys for replies!

 

Share this post


Link to post
Share on other sites
5 hours ago, Monarch said:

AM/PM  is also a question.

Well, I don't have an answer for that. I should also add that I don't recall seeing any application that uses slices of an analog clock face to select a time range* - and I always prefer to stick to established UI conventions. Perhaps you should consider a horizontal timeline with 24 (or less, if your scheduling is limited to certain hours of day only) segments, where you can select a range by clicking on the start and end segments.

In any case, selecting and conditional formatting are two quite separate issues. Selecting should result in values being entered into the StartTime and EndTime fields of the appropriate record. Conditional formatting needs to be based on these values - so it will continue working even when the values have been entered using an alternative method.

--
(*) Apple have an analog clock in System Preferences where you can select a time (not range) by dragging the minute hand. I suppose with a lot of work something like that could be implemented using SVG or HTML 5 in a web viewer.

Share this post


Link to post
Share on other sites

Thank you Comment.

I guess I have to drop it.

I will play with it for an educational purpose a bit...

So here is a more specific question:

We have three objects - A, B, C.We have three buttons - 1, 2, 3. Press 1 once - we change A to "red", press 1 again will change A to "green" and so on... Can we do it using one script?

Assigning script parameter is one step, then I tried to set variables for each object. Changing each variable will effect conditional formatting of the object. That was my idea. But I don't know how to pick the right variable from the script...

Or do  I need to create three fields instead of objects? Or is there a totally different approach?

Thank you for your help.

 

 

Share this post


Link to post
Share on other sites
4 hours ago, Monarch said:

Press 1 once - we change A to "red", press 1 again will change A to "green" and so on... Can we do it using one script?

Yes, we can, provided we have something - a field or a variable - that remembers the current state of "A". This is what I said earlier about separating between selecting and formatting: pressing the button needs to change the value of the field (or the variable); in turn, the color of the object is determined solely by the value of the field (or the variable), no matter how that value was established.

As for the script itself, you don't even need a parameter. Let's say there will be 4 states, designated as 0, 1, 2 and 3 and a field named Status to hold the current state.. Have the script set the Status field to:

Mod ( Status + 1 ; 4 )

and watch the field rotate among the values with each press of the button.

 

Now, if you want to reuse the same script for other button/field/object combinations, then pass the field name as the parameter, and have the script do:

Set Field By Name [ Get ( ScriptParameter ); Mod ( GetField ( Get ( ScriptParameter ) ) + 1 ; 4 ) ]

Alternatively, you could forgo the script and just make each button perform a single-action Set Field step.

 

The choice whether to use fields or variables depends on what's this really about: keep in mind that a variable is specific to the current user and expires at the end of the current session.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks again Comment.

The "Mod"  function is awesome! So simple and works great.

But I ve tried to do the script, like you said with "Set Field By Name" and it doesn't work for some reason... That step doesn't want to see "Get (ScriptParameter)" as the name of the field. I ve set field as text, even number, copy/paste name as parameter ( it gets in quotation automatically) but in the script it doesn't go back to that field with the same name...

Spent the whole day trying to figure it out.

Any thoughts?

But I have set, as you said again, directly "set field" without script - and it works like a charm!

 

 

 

 

Share this post


Link to post
Share on other sites
20 hours ago, comment said:

See if this works for you:

 

 

FieldNameAsParameter.fp7

Thank you so much comment!!!

I saw my mistake right away - I didn't use GetFieldName in parameter...

Now everything is working and I can get on with my life!

Thanks again.

Share this post


Link to post
Share on other sites

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

  • Similar Content

    • By jbante
      FileMaker 16 introduced a collection of built-in functions for manipulating data serialized as JSON. This makes it easier for FileMaker applications to interact with many web services. This will also make JSON the de facto standard format for scripts within FileMaker to pass parameters and results to each other, improving code sharing within the FileMaker community.
      JSON does not have a broad palette of scalar data types to choose from: text, number, boolean, and null. Even with those, FileMaker's JSONGetElement function always returns a text result, even when the serialized JSON value is a number or boolean. So I made a handful of custom functions and scripts for sending and receiving typed data with JSON.
      The module is hosted on GitHub, or you can download it directly.
    • By charlest
      Can anyone offer an explanation for this scenario.
       
      A script on the client creates a new record in table A.  Within that same script, Perform script on server is called with two parameters.  Parameter 1 is the serialized id of the record just created ( the id is created upon record commit.), and parameter 2 is a global field from a different table.  The Psos script goes to a layout for table B.  Parameter 2 is used to find the correct record.  A field in the found record is then set to parameter 1.
       
      The problem is the field set to parameter 1, has the value of parameter 1 and a carriage return.
       
      I don't know where the carriage return is coming from.  Parameter 2 is fine with no carriage return.
       
      I have tried List( param1; param2) and switching to List(param2; param1) and it produces the same results.  I am parsing using "MiddleValues( Get( ScriptParameter); 1; 1)" 
      and "MiddleValues( Get( ScriptParameter); 1; 2)
       
      Since the Id field is not editable by any user, I know it is not an input error by a user.
       
      What is going on?
       
       
  • Who Viewed the Topic

    9 members have viewed this topic:
    ryan360Works  sh2658  Warren  Joshua Rivers  amallison  Lee Smith  Lola  Christian Chojnacki  Tim Anderson 
×

Important Information

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