Page 1 of 1

WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Sat Jan 29, 2022 2:40 am
by CCH4CLIPPER
Hi All

Tried to add walert() as a replacement for Alert()

But cannot compile with error msgs

What am I missing ?


hbmk2: Error: Referenced, missing, but unknown function(s):
_DEFINEMODALWINDOW(), _DEFINEHOTKEY(), DOMETHOD(), _DEFINELABEL(),
GETPROPERTY(), _DEFINEBUTTON(), SETPROPERTY(), GETBORDERWIDTH(),
_ENDWINDOW(), _ACTIVATEWINDOW()


/*----------------------------------------------------------------------------
* WALERT()
*
* 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 0 (zero) value in case of interactive window closing.
*
* In case of translate from original Clipper code to Minigui code
* only replace "ALERT" word for "WALERT" word.
*
* Sample of Clipper code : ALERT('Please;Choice output...',{'PRINTER','SCREEN'})
* Sample of Minigui code : WALERT('Please;Choice output...',{'PRINTER','SCREEN'})
----------------------------------------------------------------------------*/

#include "minigui.ch"

#define MsgInfo( c ) MsgInfo( c, , , .f. )

*------------------------------------------
Procedure Main
*------------------------------------------

DEFINE WINDOW Win_1 ;
AT 0,0 ;
WIDTH 600 ;
HEIGHT 400 ;
TITLE 'WALERT Function Test' ;
MAIN

DEFINE BUTTON Button_1
ROW 10
COL 10
CAPTION 'Test 1'
ACTION MsgInfo( "WALERT Return = " + ltrim(str(WALERT('This is;an information screen;ONLY...',,'Information'))) )
END BUTTON

DEFINE BUTTON Button_2
ROW 40
COL 10
CAPTION 'Test 2'
ACTION MsgInfo( "WALERT Return = " + ltrim(str(WALERT('Please;Choice output...',{'PRINTER','SCREEN'}))) )
END BUTTON

DEFINE BUTTON Button_3
ROW 70
COL 10
CAPTION 'Test 3'
ACTION MsgInfo( "WALERT Return = " + ltrim(str(WALERT('Please;Choice output...',{'PRINTER','SCREEN','MAIL'}))) )
END BUTTON

DEFINE BUTTON Button_4
ROW 100
COL 10
CAPTION 'Test 4'
ACTION MsgInfo( "WALERT Return = " + ltrim(str(WALERT('Please;Choice output...',{'PRINTER','SCREEN','MAIL','FAX'}))) )
END BUTTON

DEFINE BUTTON Button_5
ROW 130
COL 10
CAPTION '&Close'
ACTION ThisWindow.Release
END BUTTON

END WINDOW

CENTER WINDOW Win_1

ACTIVATE WINDOW Win_1

Return


*------------------------------------------
FUNCTION walert( cMessage, aItems, cTitle )
*------------------------------------------
LOCAL I , J:=0 , nStart:=1 , nValue:=0 , cTextLabel
LOCAL nItemCount , nHeight , cBtnName

DEFAULT aItems TO {}
DEFAULT cMessage TO ' '

IF SET( _SET_LANGUAGE )=='ES'
DEFAULT cTitle TO 'Seleccione...'
ELSE
DEFAULT cTitle TO 'Please, select'
ENDIF
cMessage := cMessage + ';'

DEFINE WINDOW walert ;
AT 0,0 ;
WIDTH 400 ;
HEIGHT 215 ;
TITLE cTitle ;
MODAL ;
NOSIZE

ON KEY ESCAPE ACTION walert.Release

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

//******************** DRAW BUTTONS ***********************************
nItemCount := LEN(aItems) // quantity of buttons
if nItemCount > 1
nStart := 200 - (nItemCount * 80 + (nItemCount - 1) * 20) / 2
/*
80 - width of Button
20 - space between buttons
200 is half of width of walert window
*/
endif
nHeight := walert.Height
IF nItemCount <= 1
@ nHeight-70,160 BUTTON Button_1 ;
CAPTION '&OK' ;
ACTION {|| nValue := 0, walert.Release } ;
WIDTH 80 HEIGHT 28 DEFAULT
ELSE
for i:=1 to nItemCount
cBtnName := "Button_"+str(i,1)
@ nHeight-70, nStart+100*(i-1) BUTTON &cBtnName ;
CAPTION '&'+aItems ;
ACTION {|| nValue := val(right(this.name,1)), walert.Release } ;
WIDTH 80 HEIGHT 28
next i
if nItemCount > 3
walert.Width := (walert.Width) + iif(_HMG_IsXP,2,1)*GetBorderWidth()
endif
walert.Button_1.Setfocus
ENDIF

END WINDOW

CENTER WINDOW walert
ACTIVATE WINDOW walert

RETURN(nValue)

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Mon Jan 31, 2022 4:22 pm
by quartz565
Hi,
I see that you work with minigui. You can use the new and very useful function, HMG_ALERT() with many possibilities.

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Tue Feb 01, 2022 3:01 am
by CCH4CLIPPER
Hi

is hmg_alert() available in HMG.3.5 ?

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Tue Feb 01, 2022 3:30 am
by CCH4CLIPPER
Hi All

Grigory explained that the default compilation for minigui is via bcc while Harbour 3.2 is by default using mingW. Thus the minigui lib is simply not available.

CCH4CLIPPER

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Tue Feb 01, 2022 7:14 am
by AUGE_OHR
hi,

Afaik,
you must change "MINIGUI.CH" to "HMG.CH" to get it run
only Constant "_HMG_IsXP" is unknown ... but how is still using Windows XP

---

also

Code: Select all

WIDTH 80 HEIGHT 28 DEFAULT
must be change to

Code: Select all

WIDTH 80 HEIGHT 28

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Tue Feb 01, 2022 12:23 pm
by quartz565
CCH4CLIPPER wrote: Tue Feb 01, 2022 3:01 am Hi

is hmg_alert() available in HMG.3.5 ?
only with minigui

Re: WLAERT.PRG - REPLACEMENT FOR ALERT()

Posted: Tue Feb 01, 2022 1:17 pm
by CCH4CLIPPER
Its ok as I have modified Pritpal MyAlert() to.map to alert()

Thanks for responding

CCH4CLIPPER