Jump to content
Server Maintenance This Week. ×

Status Bar?


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

Recommended Posts

Can custom functions replace multiple calculations? And then just adjust if used within each table? Here's what I need:

I have a status bar at the top of every layout. This shows people certain things. It contains AccountName, Layoutname (I name the layouts to a specific task so it can be used to write to the window name also), Record indicator (record 6 of 144 found or total), the sort status (sorted or unsorted - if semi-sorted it displays unsorted).

I am just beginning to put this together and I'm already tired. crazy.gif

So already in one table I have four calculations all using Get (plus other things). And I change color of Account Name if their Privilege is Manager. And if it's a Found set, I turn the "Found" to blue and if unsorted I turn 'Unsorted' to red. And other things...

But I'm going to have to repeat this through all my tables, right? Unless I can somehow use Custom Function. Maybe create a 'STATUSBAR' function that just knows to work on each table. Then I could just have ONE calculation in each table that knows to use the current table information.

And it would need to not require a value (?) because I wouldn't know what field name to put inside it. Is this even possible? I can go into more detail if its possible but I just want to know if it could be done first. Thank you.

Linda

Link to comment
Share on other sites

Custom functions can use Get() functions, access globals, and access fields if you pass them in as parameters. They are in the same "context" as the calculation / script they are called from.

It sounds like the definition would look like:

StatusBar() defined as: <your current calculation>

Link to comment
Share on other sites

So it would work!? It would make life easier on me but would it use more resources or less if I used Custom Function to hold my calculation, instead of writing it within each table? It seems that one Custom Function would be nicer to FM than 4 calcs in each table. Is that right?

I'm excited to try this. My first Custom Function! Thank you so much Shadow!! Uh, but speed of my program is the most important - even over my own needs. It will be networked. How does FM handle it? I mean - does it take FM more work (processing) to deal with 4 calcs per table? I hope so. Because then I can use Custom Function instead and feel guilt free about it. smile.gif

Linda

Link to comment
Share on other sites

Calling a function is always a time-space tradeoff, not just for FM - in almost all languages.

It will take a small extra amount of time to call a function verus having the code inline, but you'll save because the custom function will take up a few less bytes in your file, so it will only be transferred over the network once.

I would think you're not going to be able to tell the difference, speed-wise - but you'll save developer time the next time you want to modify your status information. smile.gif

Link to comment
Share on other sites

I got a little more curious about this difference, so I decided to try an experiment.

I created a database with 10,000 records, and timed how long it took for a looping script that calls SetField on each record:

- inline calculation "5+1": 5 seconds

- custom function Six (defined as "5+1"): 5 seconds

Nonplussed, I expanded to 100,000 records:

- inlined: 48 seconds

- custom function: 53 seconds

So, that's roughly the magnitude of expense for a the function call - worth it, IMO, in exchange for the maintainence savings.

Link to comment
Share on other sites

I've been working on this StatusBar. I have made little progress. I can't even figure out how to put in a tab symbol. frown.gif Custom Functions may be worth it, but one must be smart to even use them. And it keeps wanting a parameter and I don't have one. smile.gif

Instead of having two rows, I guess I'll just use carriage returns and put it in a list. But I'm not giving up. I want my first custom function and the times you list are very worth it.

if I get tabs to work, will I have to set tabs in every layout or can I specify that in the calculation?

Linda Gent

DAC

Link to comment
Share on other sites

LindaG,

If you have no parameters, then you call your function with no parens - just "StatusBar".

As far as tabs go, you can paste a tab into a calculation, but paragraph formatting can't be changed by a calculation (as far as I know).

Here's a sample file of what your description sounds like to me.

Link to comment
Share on other sites

Thank you! I see it! It will work! If I can't control tabs in the calc then I think I'd better put each on a new line because sometimes this will be in small windows and I'm unsure if I can judge the length of the LayoutName and I don't want to have to set the tabs in each layout. Oh. I can copy your tabs it seems, but still don't know how to grab one. I think I'll keep a file with just this calc in it so I can copy and paste this invisible puppy into my work whenever I need it. Tabbing certainly isn't the way to insert a tab.

I'm trying to modify it but I can't get out of the box. I keep getting errors. crazy.gif

I have (oh please don't laugh):

Case(

Get ( PrivilegeSetName ) = "Manager", TextColor ( Get(AccountName); RGB ( 255; 0; 0 ) );

Get ( PrivilegeSetName ) = "Sales", TextColor ( Get(AccountName); RGB ( 0; 0; 255 ) );

Get ( PrivilegeSetName ) = "Admin", TextColor ( Get(AccountName); RGB ( 0; 255; 0 ) );

TextColor(Get(AccountName); RGB ( 0; 0; 0 ) );

& "

Link to comment
Share on other sites

Hello Linda,

You might like to try something along the lines of the following:

TextColor(Get(AccountName);

Choose(Position(Left(Get(PrivilegeSetName); 1); "MA"; 1; 1); 205; 13434880; 52480) ) & "

Link to comment
Share on other sites

It worked! It worked! My first! smile.gif

I admit, although I tried real hard to keep the faith as I was pasting it in, I could not see how your formula could possibly work at all. shocked.gif I had wanted the first line to change colors but I don't have time to test that and that might be overkill anyway!

Is there any way I can bold that first line? I think it would look better and I'm afraid to mess with what you have - would I wrap Add Style to the whole line? I just realized ... now I'll only have ONE place to change it - in Custom Functions! wink.gif

This is just beautiful! Thank you CobaltSky!! grin.gifsmile.gif

Lin

Link to comment
Share on other sites

LindaG said:

I had wanted the first line to change colors...

The formula is set to return the account name in red if it is'Manager', in green if it is 'Admin', or in blue if it is 'Sales' (or anything else that doesn't start with 'm' or 'a').

LindaG said:

Is there any way I can bold that first line?..

Yes. An alternative formula which has the account name in bold as well as color would be:

TextColor(TextStyleAdd(Get(AccountName); Bold);

Choose(Position("MA"; Left(Get(PrivilegeSetName); 1); 1; 1); 205; 13434880; 52480)) & "

Link to comment
Share on other sites

Alternatively, if you wanted to stick with your original case statement, you could mod Ray's suggestion as follows. Its probably not as fast, but I find it clearer (and safer, if you add a new priv set that starts with "m"):


TextColor(TextStyleAdd(Get(AccountName); Bold);

Case( Get ( PrivilegeSetName ) = "Manager"; RGB ( 255; 0; 0 );

Get ( PrivilegeSetName ) = "Sales"; RGB ( 0; 0; 255 );

Get ( PrivilegeSetName ) = "Admin"; RGB ( 0; 255; 0 );

0 /* black */ )) &

Link to comment
Share on other sites

Well, I forgot to click unstored on the calculation. Now my sort/unsort works. But the account name still won't change color. I create account name Linda and create a new Privilege Set Manager (and even description as Manager) and close. When I log on as Linda, the account name is blue. I have not used accounts before. Am I doing something wrong? I also created George as Sales and he comes up blue also. Admin (the original one), sales and managers are all blue.

Do I have to put brackets around the Privilege set like [Full Access] shows?

I also have problems with the color on my system. But I can change calc colors to red and green so this should work the same, right? But I can't color my relationship graphs either. Any ideas what I am doing wrong?

Oh! It bolds and looks perfect except for the account name not changing colors. Can anyone give me a plain file that works right so I can compare and see if it's me or my system? smile.gif

Linda

Link to comment
Share on other sites

Hi Linda,

Apologies - the error was mine. blush.gif

In the original formula I posted, two of the parameters were presented in reverse order, which was causing the color to always return as blue.

Attached is a working example which has the parameters in the correct order. wink.gif

LindaG.zip

Link to comment
Share on other sites

No apologies necessary, Ray. Thank you! It works great! I get colors! grin.gif

Uh. It took me awhile to figure out how you did this with globals (no script). But it's specify button. I love this idea and I'm going to use it also - thank you for this also. wink.gif

Two small quick questions, I hope. I've been studying this for a long time:

1) The Replace part. What is the 8 for? Both phrases 'records found' and 'total records' don't have 8 characters! I think it will make sense if I figure out the 8.

2) Can you explain how the first line knows which color? I figured it's the MA - M for Manager and A for Admin but I can't quite decipher it - okay, I can't AT ALL. And I want to because, as The Shadow points out, I may want other colors (Lord forbid) for other sets. I can be sure to name them with different beginning letters if I can figure it out. But how does it KNOW which color? And I see no way the A is specified. What if I wanted to add to it, like MAG? Can you help me understand it please?

I think I figured out the last part. 0 is unsorted, 1 is sorted and 2 is semi-sorted? Am I right? Is this what choose is doing? Even if you're to busy to respond, that's alright! I'm very happy with this. And I even like your tabs. I think I actually like this stuff now, even if I don't understand much of it! And thank you too The Shadow for helping, I have learned alot from both of you on this whole problem. cool.gif

Linda

Link to comment
Share on other sites

Oh! I got the first line! Choose again!!! It'll take a third item, won't it!!! And I understand the color numbers too! After studying Choose, now the first line makes (sorta) sense - but I won't have to mess with those 1's (good thing since I didn't understand them) but I know ONE of them says just use one left character. Thanks. smile.gif:

Link to comment
Share on other sites

Glad to hear it's working for you.

Some quick answers to your quick questions:

1) The 8 denotes the position of the 's' character in the " records found..." string. The replace function is replacing the 8th character with nothing ("") when Get(FoundCount) = 1.

2) Colors are represented by a number. If you don't kknow what color you want, you can use the RGB( ) function to 'mix' a color number on the fly from its red, green and blue components - and the RGB function computes the corresponding number. But if you *know* what color you want, it's more efficient to reference it directly by its number. You can find out the numbers easily by using the RGB function in a test file and then entering the numbers into your custom function formula, which saves the extra processing cycles of computing the RBG values every time the function evaluates.

The appropriate color number is then being selected using the Choose( ) function based on the position of the initial letter of the privilege set name in the literal string supplied to the Position( ) function.

And yes, the final Choose( ) function is mapping the SortState codes to their text equivalents, as you say. wink.gif

Link to comment
Share on other sites

This topic is 7288 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.