Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Random Quote Board


FredP
 Share

Recommended Posts

Hey Guys,

 

A fun little thing we do is to have a random quote appear in different places in different software around the office. i was thinking of incorporating it into one of our FMP databases.

 

ideally i would like to radomly put on on our "Main Menu".

 

Can someone help me with the methodology i woould use to randomly display the field "Quote" from a table of quotes that would have a serial ID to the quotes.

 

I would like people to be able to add quotes to it, and have it be smart enough to know that the current number to randomize between went up each time a quote is added...etc.etc.... thanks

Link to comment
Share on other sites

here's a custom function that will pick a "random" number that falls into a range.

 

RestrictedRandom ( MaxRelatedNumber ; MaxLengthRelatednumber ) =

 

Let
(
[
try=
Right
(Random;MaxLengthRelatedNumber)
;
result=
Case(try>MaxRelatedNumber;RestrictedRandom(MaxRelatedNumber;MaxLengthRelatedNumber);try)
];
result
)//end let

 

I see you don't have Fm 8 Advanced so you'd need someone who can paste this into your solution. It could be a scripted procedure I guess, I'll take a stab at that if you can't make use of the CF (I'd do it for you if you wish).

 

the sample shows how it functions; I used it in an auto-enter calculation that triggers when a new main record is created. You could also use it in a script at startup, at pageload, etc.

 

kjoe

 

PS since Random generates a number between 0 and 1 with a precision of 17 decimals, the above will work well for ranges with maximum 17 digits. But since that would mean a maximum of 99.999.999.999.999.999 quotes, I don't think there are any practical limits to this.

Link to comment
Share on other sites

Another idea ... create a cartesian join between Menu and Quotes (join any two fields except container using the X operator). Then create an unstored calculation (text) in Menu with:

 

GetNthRecord ( Quotes::phrase ;  Int ( Random * Count ( Quotes::QuoteID )) + 1 )

Place this calc on your menu. Every time a User changes layout (and back), refreshes window, preview etc, will refresh the unstored calculation and display a new phrase. Be sure and right-click that calc and Field Control > Behavior and uncheck 'Allow field Entry in Browse mode.' It won't matter whether there are one (or more) records in Menu but you must have one.

 

You had better add functionality for Users to add to it quickly ... otherwise they will begin to complain that they see the same messages over and over.

Link to comment
Share on other sites

 Share



×
×
  • Create New...

Important Information

Terms of Use