Page 1 of 2

Mapping Clipper Alert() to MsgYesNo()

Posted: Thu Mar 05, 2009 1:58 pm
by CCH4CLIPPER
Hi

I use Alert() everywhere in FAS4HMG as my dialog of choice.
Do you think it is a good idea to create a say cch4clipper.ch file and map Alert() to MsgYesNo() ?

CCH
http://cch4clipper.blogspot.com

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Thu Mar 05, 2009 2:20 pm
by esgici
CCH4CLIPPER wrote:Hi

I use Alert() everywhere in FAS4HMG as my dialog of choice.
Do you think it is a good idea to create a say cch4clipper.ch file and map Alert() to MsgYesNo() ?

CCH
Hi CCH

AFAIK Alert() have multiple ( unlimited) options. MsgYesNo() don't accept any option and support automatically two ( "yes" and "no" ).

If all of your Alert()s have always "yes/no", you may map it. Still you have change your source code, because of parameters aren't identical.

Regards

--

esgici

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Thu Mar 05, 2009 3:27 pm
by gfilatov
CCH4CLIPPER wrote:Hi

I use Alert() everywhere in FAS4HMG as my dialog of choice.
Do you think it is a good idea to create a say cch4clipper.ch file and map Alert() to MsgYesNo() ?
Hi CCH,

Please be so kind to review the following direct replacement for Clipper ALERT() function:
/*----------------------------------------------------------------------------
* $Id: walert.prg,v 1.0 2006/09/08 02:42:56 $
*
* Direct replacement for Clipper ALERT() function
*
* Copyright 2006 Ricardo Sassy <rsassy@gmail.com>
* www - http://www.harley.com.ar
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
/*----------------------------------------------------------------------------
* FUNCTION walert( cMessage, aItems, cTitle ) ===> nValue returned
* cMessage: Message to be displayed inside ALERT frame. Can contain ";"
* character(s) to line feed efect.
* aItems : (optional) An array of choices. If empty, a "OK" button will
* be displayed and return "0" value.
* cTitle : (optional) A title for ALERT window. If empty, default to "choice" message.
*
* Function return numeric value from 1 to 4 according to button pressed
* or zero "0" value in case of interactive window close.
*
* In case of translate from original Clipper code to ooHG/Minigui code
* only replace "ALERT" word for "WALERT" word.
* Sample Clipper code : ALERT('Please;Choice output...',{'PRINTER','SCREEN'})
* Sample ooHG/Minigui code: WALERT('Please;Choice output...',{'PRINTER','SCREEN'})
* WARNING !!!!: Pay attention that function put "OFF" INTERACTIVECLOSE value before exit.
* This could be incorrect for you program structure.
/*----------------------------------------------------------------------------/*


FUNCTION walert( cMessage, aItems, cTitle )
LOCAL I:=0 , J:=0 , nStart:=1 , nValue:=0
DEFAULT aItems TO {}
DEFAULT cMessage TO ' '
IF SET( _SET_LANGUAGE )=='ES'
DEFAULT cTitle TO 'Seleccione...'
ELSE
DEFAULT cTitle TO 'Please, select'
ENDIF
cMessage := cMessage+';'
SET INTERACTIVECLOSE ON
DEFINE WINDOW walert ;
AT 0,0 ;
WIDTH 400 HEIGHT 215 ;
TITLE cTitle ;
ICON 'MAIN' ;
TOPMOST ;
NOMAXIMIZE NOSIZE ;
ON INTERACTIVECLOSE {|| nValue := 0, walert.Release }

//******************** DISPLAY MESSAGE *******************************
FOR I=1 TO LEN(cMessage)
IF SUBST(cMessage,I,1)=';'
++J
cTexLabel := 'text'+STR(J,1)
@ (J*15)-10,016 LABEL &cTexLabel WIDTH 368 HEIGHT 20 VALUE SUBST(cMessage,nStart,I-nStart) ;
FONT 'Sans serif' SIZE 10 CENTERALIGN
nStart := I+1
ENDIF
NEXT

//******************** DRAW BUTTONS ***********************************
IF LEN(aItems) <= 1
@ 150,160 BUTTON Button_1 ;
CAPTION '&OK' ;
ACTION {|| nValue := 0, walert.Release } ;
WIDTH 80
ENDIF

IF LEN(aItems) = 2
@ 150,105 BUTTON Button_1 ;
CAPTION '&'+aItems[1] ;
ACTION {|| nValue := 1, walert.Release } ;
WIDTH 80

@ 150,215 BUTTON Button_2 ;
CAPTION '&'+aItems[2] ;
ACTION {|| nValue := 2, walert.Release } ;
WIDTH 80
ENDIF

IF LEN(aItems) = 3
@ 150,055 BUTTON Button_1 ;
CAPTION '&'+aItems[1] ;
ACTION {|| nValue := 1, walert.Release } ;
WIDTH 80

@ 150,160 BUTTON Button_2 ;
CAPTION '&'+aItems[2] ;
ACTION {|| nValue := 2, walert.Release } ;
WIDTH 80

@ 150,265 BUTTON Button_3 ;
CAPTION '&'+aItems[3] ;
ACTION {|| nValue := 3, walert.Release } ;
WIDTH 80
ENDIF

IF LEN(aItems) = 4
@ 150,016 BUTTON Button_1 ;
CAPTION '&'+aItems[1] ;
ACTION {|| nValue := 1, walert.Release } ;
WIDTH 80

@ 150,112 BUTTON Button_2 ;
CAPTION '&'+aItems[2] ;
ACTION {|| nValue := 2, walert.Release } ;
WIDTH 80

@ 150,208 BUTTON Button_3 ;
CAPTION '&'+aItems[3] ;
ACTION {|| nValue := 3, walert.Release } ;
WIDTH 80

@ 150,304 BUTTON Button_4 ;
CAPTION '&'+aItems[4] ;
ACTION {|| nValue := 4, walert.Release } ;
WIDTH 80
ENDIF

END WINDOW
CENTER WINDOW walert
ACTIVATE WINDOW walert
SET INTERACTIVECLOSE OFF
RETURN(nValue)

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Thu Mar 05, 2009 3:52 pm
by CCH4CLIPPER
Hi Grigory

I think I saw a link to walert() somewhere in the net this afternoon. Could be at extendedHMG site...
But when I clicked on the link, I get the 404 not found error :-(

So, I couldn't believe it when you posted walert().
I will checked it out and report back here.

TQVM

CCH
http://cch4blogspot.com

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 6:07 am
by CCH4CLIPPER
Hi

Is walert.prg compatible with HMG ?

Using compile.bat to compile walert.prg, I get :-

walert.prg(34) Error E0030 Syntax error: "syntax error at 'AITEMS'"

walert.prg(35) Error E0030 Syntax error: "syntax error at 'CMESSAGE'"

walert.prg(37) Error E0030 Syntax error: "syntax error at 'CTITLE'"

walert.prg(39) Error E0030 Syntax error: "syntax error at 'CTITLE'"

walert.prg(42) Error E0030 Syntax error: "syntax error at 'INTERACTIVECLOSE'"

walert.prg(50) Error E0030 Syntax error: "syntax error at 'WINDOW'"

walert.prg(58) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(68) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(75) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(80) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(87) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(92) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(97) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(104) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(109) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(114) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(119) Error E0030 Syntax error: "syntax error at '@'"

walert.prg(122) Error E0030 Syntax error: "syntax error at 'END'"

walert.prg(123) Error E0030 Syntax error: "syntax error at 'WINDOW'"

walert.prg(124) Error E0030 Syntax error: "syntax error at 'WINDOW'"

walert.prg(125) Error E0030 Syntax error: "syntax error at 'INTERACTIVE'"

Where should I go from here ?

CCH
http://cch4clipper.blogspot.com

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 7:30 am
by Rathinagiri
Had you added #include "minigui.ch" ?

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 9:30 am
by esgici
Hi CCH

Please also take a look to MsgMulti at HMG Resources \ HMG Samples \ Misc Samples topic.

Regards

--

esgici

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 9:40 am
by CCH4CLIPPER
Hi Rathinagiri

Yes, I just did and still cannot compile walert.aprg

Start...
Missing ".o" files: WALERT.O

WALERT.prg(37) Error E0030 Syntax error: "syntax error at 'AITEMS'"

WALERT.prg(38) Error E0030 Syntax error: "syntax error at 'CMESSAGE'"

WALERT.prg(40) Error E0030 Syntax error: "syntax error at 'CTITLE'"

WALERT.prg(42) Error E0030 Syntax error: "syntax error at 'CTITLE'"

WALERT.prg(128) Error E0030 Syntax error: "syntax error at 'INTERACTIVE'"
Finished With Errors.

CCH
http://cch4clipper.blogspot.com

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 10:13 am
by gfilatov
Hi CCH

Please add also #include "common.ch" :!:

Re: Mapping Clipper Alert() to MsgYesNo()

Posted: Fri Mar 06, 2009 11:55 am
by CCH4CLIPPER
Hi Grigory

Yup, no come error but testing out alert() does not give any response

Function ReindexAll()
nChoice:=Alert('Reindex All Files',{'Yes','No'})
Alert(Str(nChoice))

Return

DEFINE TOOLBAR ToolBar_1 BUTTONSIZE 32,24 BORDER
BUTTON Button_Reindex ;
CAPTION '&Reindex All' ;
PICTURE 'task-2.bmp' ;
ACTION ReindexAll()
END TOOLBAR

Clicking Reindex Btn does not give any response at all.
FYI, Using MsgInfo('Reindex') does work, so I think walert.prg has some issues.

Would appreciate any help here.


CCH
http://cch4clipper.blogspot.com