Mapping Clipper Alert() to MsgYesNo()

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

CCH4CLIPPER
Posts: 140
Joined: Tue Mar 03, 2009 8:59 am

Mapping Clipper Alert() to MsgYesNo()

Post 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
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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
Viva INTERNATIONAL HMG :D
User avatar
gfilatov
Posts: 1068
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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)
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
CCH4CLIPPER
Posts: 140
Joined: Tue Mar 03, 2009 8:59 am

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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
CCH4CLIPPER
Posts: 140
Joined: Tue Mar 03, 2009 8:59 am

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Mapping Clipper Alert() to MsgYesNo()

Post by Rathinagiri »

Had you added #include "minigui.ch" ?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Mapping Clipper Alert() to MsgYesNo()

Post by esgici »

Hi CCH

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

Regards

--

esgici
Viva INTERNATIONAL HMG :D
CCH4CLIPPER
Posts: 140
Joined: Tue Mar 03, 2009 8:59 am

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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
User avatar
gfilatov
Posts: 1068
Joined: Fri Aug 01, 2008 5:42 am
Location: Ukraine
Contact:

Re: Mapping Clipper Alert() to MsgYesNo()

Post by gfilatov »

Hi CCH

Please add also #include "common.ch" :!:
Kind Regards,
Grigory Filatov

"Everything should be made as simple as possible, but no simpler." Albert Einstein
CCH4CLIPPER
Posts: 140
Joined: Tue Mar 03, 2009 8:59 am

Re: Mapping Clipper Alert() to MsgYesNo()

Post 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
Post Reply