Calendar Status and Operators

Support for our integrated Contact Manager, Calendar, and Project Tracker.
Posts: 135
Joined: Fri Sep 28, 2007 3:09 pm
Location: UK
PostPosted: Tue May 04, 2010 3:33 pm
If you try to use operators within the status text, the colour coding will fail.

This is because the colours are written to a variable, a variable name cannot contain any operators.

For example :

A or B
C and D
A & B

I only came to realise this after a few of our users reported a lot of black colours, after looking closer, I realised they where using status like

Off / Holiday and MOT / Service

So after a little bit of 'experimenting' here is a solution.
I have tried to write it using a newer calendar version, but it may not be 100% correct since I use my own colour coding implementation...

Basically, the idea is to strip out any operators before creating the variables and also before creating the arrays used by the calendar
So, A & B becomes AB or Yes AND No becomes YesNo


Script : Load Source Colors (or Apply Color Settings in new versions)

Change the code to substitute out these operators, before building the evaluate string

Code: Select all

Let (

NewStatus = Substitute ( CalendarColors::Name ;
[" and " ; ""] ;
[" or " ; ""] ;
[" & " ; ""] ;
etc .....
[" not " ; ""]
) ;

Evaluate ( "Let ($$sc_Color" & NewStatus & " = " & CalendarColors::ColorRGBValue & " ; \"\")")

)




Then in Write One Filemaker Event in iCal Format, edit the line which gets the status

Code: Select all

Set Variable [$scical_Status; Value: Substitute ( GetField ($$sc_FieldForStatus) ; [" and " ; ""] ; [" or " ; ""] etc etc etc  ) ]



As mentioned above, I have modified my own integration which may differ from later versions of SeedCode Calendar, so it may need adapting to work in the current version. But the principle should be the same.
Steve Wright
SWS Solutions
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Tue May 04, 2010 3:55 pm
Hey Steve,

Good timing. I've been working on this also as a customer had statuses with math operators in them:

Partial 3/4
Hold - Us
Parts+

Came up with a low impact solution that uses Code() to transform the status name into a number:

1. Edit the script "Apply Color Settings { Close , Dont Refresh }" and find the Set Variable step in our loop. Wrap the color name in the Code function so it looks like this:

Evaluate ( "Let ( $$sc_Color" & Code( CalendarColors::Name ) &" = " & CalendarColors::ColorRBGValue & " ; \"\" )" )

2. Edit the script "Write One FileMaker Event in iCal Format" and find where we set the variable $scical_Status. Wrap that as well so it looks like this: Code ( GetField ( $$sc_FieldForStatus ) )

I think we'll add this in the next build, but I'm still testing it. Variable names can only be 100 characters long, so this could fail if you had status names over 45 characters long.
John Sindelar
SeedCode
Posts: 135
Joined: Fri Sep 28, 2007 3:09 pm
Location: UK
PostPosted: Tue May 04, 2010 4:03 pm
:wink:

Im sure that will run a lot faster, especially on a full calendar...
Now why didn't I think of that..

Limiting the status name is not an issue for me, Ill implement it now and give it some testing...

Thanks
Steve Wright
SWS Solutions
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Tue May 04, 2010 4:12 pm
That would be cool Steve; thanks!
John Sindelar
SeedCode
Posts: 135
Joined: Fri Sep 28, 2007 3:09 pm
Location: UK
PostPosted: Tue May 04, 2010 4:35 pm
Dont forget to edit z_sc_ColorCalc in the events table if you use it

Let ( [

s = code(status)

// above is the field you're using to color code events.......

P.S Seems to be working quite well, I had quite a few test statuses... sure beats a long string of substitutions.

(statuses hmm.. is that the way its written)
Steve Wright
SWS Solutions
Posts: 30
Joined: Tue Oct 06, 2009 1:51 pm
Location: Austin, Texas
PostPosted: Thu Jun 24, 2010 12:16 pm
I've got the same issue here and I've followed the guidance for using the Code() function as outlined on this thread. Those changes fixed the problem when I used a status value with the operator "Not" in it, but it still breaks with the operator "Or". Very odd. The exact text that still breaks color coding for me is "Open New or Current".
Hedrich Michaelsen
Austin TX
512-458-2099
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu Jun 24, 2010 12:28 pm
Hi, it's not the "or", it's the length. Using this code() mod your statuses can't be too long. Yours is 1 character too long: you'll find that "Open New or Curren" works.

Hope that helps,

John
John Sindelar
SeedCode
Posts: 30
Joined: Tue Oct 06, 2009 1:51 pm
Location: Austin, Texas
PostPosted: Thu Jun 24, 2010 12:47 pm
Aha! Well, this is the first time I've used Code()...

I'd already solved it by changing the status value to "Open New/Current", which works just fine and now I know why.

Thanks! I've learned something new today...
Hedrich Michaelsen
Austin TX
512-458-2099
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu Jul 22, 2010 5:46 pm
Code() is a cool, quick fix for this, but it has limitation as to how long a string it can encode into a variable name. A more through fix is to add a custom function to your solution. Call this "SeedCode_NoOperators" and define it like this:

Code: Select all
/*

SeedCode_NoOperators ( string )

Removes operators from fields we want to use as variable names

*/

Substitute ( string ;
["\"" ; "" ] ;
["(" ; "" ] ;
[")" ; "" ] ;
["+" ; "" ] ;
["-" ; "" ] ;
[">" ; "" ] ;
["<" ; "" ] ;
["=" ; "" ] ;
["≠" ; "" ] ;
["≤" ; "" ] ;
["≥" ; "" ] ;
["&" ; "" ] ;
["^" ; "" ] ;
["/" ; "" ] ;
["*" ; "" ] ;
[" or " ; "" ] ;
[" and " ; "" ] ;
[" not " ; "" ] ;
[" xor " ; "" ]
)


Now use "SeedCodeNoOperators(" in place of "Code(" in the modifications above.
Last edited by John Sindelar on Fri Jul 23, 2010 1:33 pm, edited 1 time in total.
John Sindelar
SeedCode
Posts: 30
Joined: Tue Oct 06, 2009 1:51 pm
Location: Austin, Texas
PostPosted: Fri Jul 23, 2010 1:17 pm
I like that! Will do it now....
Hedrich Michaelsen
Austin TX
512-458-2099
Posts: 30
Joined: Tue Oct 06, 2009 1:51 pm
Location: Austin, Texas
PostPosted: Fri Jul 23, 2010 2:01 pm
Caveat with this custom function that I found right off...

If the string is, e.g., "Do Not Schedule", the CF doesn't work because the Substitute function is Case sensitive. To be safe you might want to revise the CF to wrap Lower () around "string".

Code: Select all
/*

SeedCode_NoOperators ( string )

Removes operators from fields we want to use as variable names

*/

Substitute ( Lower ( string ) ;
["\"" ; "" ] ;
["(" ; "" ] ;
[")" ; "" ] ;
["+" ; "" ] ;
["-" ; "" ] ;
[">" ; "" ] ;
["<" ; "" ] ;
["=" ; "" ] ;
["≠" ; "" ] ;
["≤" ; "" ] ;
["≥" ; "" ] ;
["&" ; "" ] ;
["^" ; "" ] ;
["/" ; "" ] ;
["*" ; "" ] ;
[" or " ; "" ] ;
[" and " ; "" ] ;
[" not " ; "" ] ;
[" xor " ; "" ]
)
Hedrich Michaelsen
Austin TX
512-458-2099
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Fri Jul 23, 2010 2:32 pm
Nicely done!
John Sindelar
SeedCode
Posts: 18
Joined: Tue Sep 29, 2009 9:25 am
PostPosted: Fri Sep 24, 2010 2:42 pm
I just wanted to say that this thread solved the problem for me. Client wants to Categorize events like Class (Public) and Class ( Contract ), and those parens resulted in black. I didn't find this thread the first time I searched, but in the end the Custom Function (including the Lower () function) worked like a charm.

John, you'll save some users a headache if you can include this mod in your solution.

Thanks for a great calendar,
-jb
SeedCode Staff
SeedCode Staff
Posts: 2764
Joined: Thu Nov 20, 2003 11:01 am
PostPosted: Thu Nov 11, 2010 8:29 am
Thanks jb. We have added this to the latest builds of Pro and Complete and it is making things a lot easier. We did omit a few operators though, so folks are adding commas and semicolons into the function if they want to use those in their statuses.

Best,

John
John Sindelar
SeedCode

Return to SeedCode Calendar

Who is online

Users browsing this forum: No registered users and 1 guest

(855) SEEDCODE
[email protected]
Follow us: