#IF .F.
This method was written in 5.0 and I have use it since. It has been a great FOR using interactively (command window, etc.) AND from a program. It was best in prior 7.0 era, when the messagebox returned an error if you passed in non-character data.
It is still a great tool today.
1. It provides your app with common looking messageboxes.
2. It is whole lot more readable and easier to remember than those cryptic messagebox parameters.
3. Easy to program using it.
This one is for YESNO, I'll share a few of my others. They include STOP() and INFO()
Notice, the proper ICON is displayed (see footnote at bottom), and the system title is displayed. If a title is not passed it, it will look for a public memory variable (change it to your needs)
but for this example I'll call it gcSystem.
COPY all this text including comments because the compile will ignore the since they are contained in #IF/END, into a program. Save the program and execute it.
You'll see how it works.
#ENDIF
PUBLIC tcSystem
tcSystem = "Tek Tip"
IF YESNO([Are you feeling well]) = [YES]
MESSAGEBOX([I am happy to hear you are well.],[Tek-Tip])
ELSE
MESSAGEBOX([I hope you are feeling better soon.],[Tek-Tip])
ENDIF
* Isn't this a nice easy way to program?
*****************************************************************************
PROCEDURE YESNO
LPARAMETER tcMessage,tcTitle,tnDefaultButton
* syntax:
* lcans = YESNO[Are you happy])
* default is the NO button unless you tell it otherwise with a 2nd parm.
DO CASE
CASE PCOUNT() = 0
tcMessage = [Duh... No Message Passed]
tnDefaultButton = 2
CASE PCOUNT() = 1
tcTitle = tcSystem
tnDefaultButton = 2
CASE PCOUNT() = 2
DO CASE
CASE TYPE('tcTitle') = [C]
* they passed in a title but no default button.
tnDefaultButton = 2
CASE TYPE('tcTitle') = [N]
* they passed in a default button, but no title
IF tcTitle = 1
tnDefaultButton = 1
ELSE
* anything else we'll set to NO
tnDefaultButton = 2
ENDIF
tcTitle = tcSystem
OTHERWISE
tcTitle = tcSystem
tcDefaultButton = 2
ENDCASE
CASE PCOUNT() = 3
DO CASE
CASE TYPE('tcTitle') = [C] AND TYPE('tnDefaultButton') = [N]
* this what is expected.
IF tnDefaultButton = 1
* YES
ELSE
* only 1 and 2 are valid
* set all others to 2
tnDefaultButton = 2
ENDIF
CASE TYPE('tcTitle') = [N] AND TYPE('tnDefaultButton') = [C]
* let's assume the dumb-dumb (I hope it's not me) passed
* the parms in backwards.
LOCAL lcTemp
lcTemp = tnDefaultButton
tnDefaultButton = tcTitle
IF tnDefaultButton = 1
* YES
ELSE
* only 1 and 2 are valid
* anything other 1 we'll set to 2
tnDefaultButton = 2
ENDIF
tcTitle = m.lcTemp
OTHERWISE
* we can only do so much.
tcTitle = tcSystem
tnDefaultButton = 2
ENDCASE
ENDCASE
#IF .F. Footnote: This information was provided by Craig Berntson. It originated on MS Developers guidelines:
"...the question mark message icon is no longer recommended, because it does not clearly represent a specific type of message and because the phrasing of a message as a question could apply to any message type. In addition, users can confuse the message symbol question mark with Help information. Therefore, do not use this question mark message symbol in your message boxes. The system continues to support its inclusion only for backward compatibility."
I like to use the question mark in my messagebox when asking a question. You may wish to change it to fit UI Guidelines if you prefer.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.