/* * $Id$ */ /* * Harbour Project source code: * DEFAULT.CH some default definition to HTMLLIB * * Copyright 2000 Manos Aspradakis * www - http://www.harbour-project.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version, with one exception: * * The exception is that if you link the Harbour Runtime Library (HRL) * and/or the Harbour Virtual Machine (HVM) with other files to produce * an executable, this does not by itself cause the resulting executable * to be covered by the GNU General Public License. Your use of that * executable is in no way restricted on account of linking the HRL * and/or HVM code into it. * * 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. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit * their web site at http://www.gnu.org/). * */ /* * The following parts are Copyright of the individual authors. * www - http://www.harbour-project.org * * Copyright 2000 Luiz Rafael Culik * Porting this library to Harbour * * See doc/license.txt for licensing terms. * */ #ifndef _DEFAULT_CH_ //#ifndef _BOX_CH //#include "box.ch" //#endif #ifndef _INKEY_CH #include "inkey.ch" #endif #ifndef _COMMON_CH #include "common.ch" #endif #xTranslate PERCENT( , ) => ; ( ( * ) / 100 ) // --> Default parameters #xcommand DEFAULT := ; [, := ] => ; := IIf( == nil, , ) ;; [ := IIf( == nil, , ); ] #xcommand DEFAULT TO [, TO ] ; => ; IF == NIL ; := ; END ; [; IF == NIL ; := ; END ] // --> OOPs #xtranslate BYNAME [, ] => :: := [; :: := ] #xtranslate BYNAME DEFAULT => :: := BYDEFAULT , #xtranslate BYDEFAULT , => IIF( == NIL, , ) // --> Save/Restore video state... #xtranslate SaveState() => { row(), ; col(), ; SetColor(), ; SetCursor(), ; SaveScreen(,,,,) } #xtranslate RestState() => DispBegin() ;; RestScreen(,,,,\[\5]) ;; SetColor(\[\3] ) ;; SetCursor(\[\4]) ;; SetPos(\[\1], \[\2] ) ;; DispEnd() // --> Save/Restore Table state #xTranslate DbSaveState() => IIF( USED(),; { Select(), ; Recno(), ; OrdBagName(0),; OrdSetFocus() ; },; NIL ) #xTranslate DbRestState( ) => IIF( != NIL, ; ( Select( \[\1] ), ; OrdListAdd(\[\3] ), ; OrdSetFocus(\[\4] ), ; DbGoto(\[\2] )),) // --> Display a Message at MAXROW() with optional colour... #xTranslate Message(,) => ; DispOutAt( maxrow(), 0, PadC(, MaxCol()+1 ), ; IIF( EMPTY(#), "R/W", # ) ) // --> Display a backdrop desktop with optional color #xTranslate DeskTop([]) => ; DispBox( 0,0,maxrow(),maxcol(), replicate("±",9), [] ) // --> Display a box with shadow (without savescreen() ) #xTranslate ShadBox( , , , , , ) ; => ; DispBegin() ;; RESTSCREEN( +1,+2,+1,+2,; TRANSFORM( ; SAVESCREEN( +1,+2,+1,+2 ),; REPLICATE( 'X', ( -+1 ) * ( -+1 ) ) ) );; DispBox( , , , , [], [] );; SetPos( +1, +1 );; DispEnd() // --> Display a box with shadow: Saves screen for WClose() // --> *MUST* pass to variable, e.g. // --> // --> LOCAL aWin := WOpen( 10, 10, 20, 30, B_DOUBLE + " ", "N/W" ) // --> #xTranslate WOpen( , , , , [], [] ) ; => ; { , , +1, +2, ; SAVESCREEN( , , +1, +2 ) } ;; DispBegin() ;; RESTSCREEN( +1,+2,+1,+2,; TRANSFORM( SAVESCREEN( +1,+2,+1,+2 ),; REPLICATE( 'X', ( -+1 ) * ( -+1 ) ) ) );; DispBox( , , , , ; IIF(EMPTY(#), "ÚÄ¿³ÙÄÀ³ ", ), ; IIF(EMPTY(#),"W/B", ) );; SetPos( +1, +1 );; DispEnd() // --> Display a Caption for a WOpen() window #xTranslate WTitle( , , ) => ; DispBox( \[1\], \[2\], ; \[1\], \[4\]-2, ; replicate(" ",9), ; IIF( EMPTY(#), "b/w", # ) ) ;; DispOutAt( \[1\], \[2\], ; PADC(, (\[4\]-\[2\])-1, " " ), ; IIF( EMPTY(#), "b/w", # )) // --> Closes a window created with WOpen() - Restores screen #xTranslate WClose() => RestScreen( \[1\], \[2\], ; \[3\], \[4\], ; \[5\] ) // --> Save/Restore full screen - *MUST* pass to/from var #xtranslate ScreenSave() => SAVESCREEN( 0, 0, 24, 79 ) #xtranslate ScreenRest( ) => RESTSCREEN( 0, 0, 24, 79, ) // --> Build a Picture template #xtranslate CAPFIRST() => ( "!" + REPLICATE( "X", LEN( ) -1 )) // --> Array shrink #xTranslate ASHRINK( ) => ; ADEL ( , LEN( ) ) ; ; ASIZE( , LEN( ) - 1 ) // --> Number to Trimmed String #xTranslate NTRIM( ) => LTRIM(STR( )) #xTranslate NUMTRIM( ) => LTRIM(STR( )) // --> Convert logical to character #xtranslate LTOC() => IIF( , "T", "F") // --> Convert character to logical #xTranslate CTOL() => IIF( $ "TtYy", .T., .F.) // --> Left trim a numeric #xtranslate LSTR() => LTRIM( Str( ) ) // --> Carriage Return + Line Feed #xtranslate CRLF() => ( + CHR(13)+CHR(10) ) #xtranslate CRLF() => CHR(13) + CHR(10) // --> create a Get/Set Block #define GSB( xVar) {|x| IIF(x == NIL, xVar, xVar := x )} #xtranslate GetSetBlock() => {|x| IIF(x == NIL, , := x )} #translate GETSET( , ) => ; := IIF( == NIL, , := ) // --> Convert Character String to Code Block #xTranslate COMPILE() => &("{||" + + "}") // --> Errors... #define Beep() Tone(300,3) #xTranslate ErrorTone() => ( TONE( 1000,.01), ; TONE( 1400,.01), ; TONE( 1800,.01) ; ) #define DEF_PATH SET(_SET_DEFAULT) // --> GETs ... //#define OK_GETS() LASTKEY() != K_ESC .AND. UPDATED() /* DATA TYPES */ #xtranslate IS_ARRAY() => (VALTYPE()=="A") #xtranslate IS_BLOCK() => (VALTYPE()=="B") #xtranslate IS_CHAR() => (VALTYPE()=="C") #xtranslate IS_DATA() => ( \>=32 .AND. \<= 253) #xtranslate IS_DATE() => (VALTYPE()=="D") #xtranslate IS_DEF() => !(TYPE() $ "UE") #xtranslate IS_DIGIT() => ISDIGIT() #xtranslate IS_INT() => ()==INT() ) #xtranslate IS_LOGIC() => (VALTYPE()=="L") #xtranslate IS_MEMO() => (VALTYPE()=="M") #xtranslate IS_NUM() => (VALTYPE()=="N") #xtranslate IS_OBJECT()=> (VALTYPE()=="O") #xtranslate IS_TIME() => (VAL(LEFT ,2)) \< 24 .AND. ; VAL(SUBSTR(,4,2)) \< 60 .AND. ; VAL(RIGHT(,2 )) \<60 ) #translate ISNIL( ) => ( == NIL ) #translate ISARRAY( ) => ( valtype( ) == "A" ) #translate ISBLOCK( ) => ( valtype( ) == "B" ) #translate ISCHARACTER( ) => ( valtype( ) == "C" ) #translate ISDATE( ) => ( valtype( ) == "D" ) #translate ISLOGICAL( ) => ( valtype( ) == "L" ) #translate ISMEMO( ) => ( valtype( ) == "M" ) #translate ISNUMBER( ) => ( valtype( ) == "N" ) #translate ISOBJECT( ) => ( valtype( ) == "O" ) #command REPEAT => DO WHILE .T. #command UNTIL <*lexpr*> => IF (); EXIT ; END ; ENDDO #command IF THEN <*statement*> =>; IIF() ; ; END #command IF THEN ELSE =>; IIF() ; ; ELSE ; ; END #define _DEFAULT_CH_ #endif