Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Artful Two for Clipper 5.0 - /* http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
/*
  Artful.ch
  Standard Clipper header file for Artful.Lib v2.0
*/

/* thanks to Mike Schinkel for this: */
#command DEFAULT <var1> TO <value1> [,<varN> TO <valueN>] ;
=>;
                 if ( <var1> == NIL ); <var1>:= <value1>;  end;
                 [;if ( <varN> == NIL ); <varN>:= <valueN>;  end]


/*
  At the present time we are not aware of a useful outboard
  memory packer for Clipper 5.0.
 */

#define MEMPACK()


/*
  Constants
 */

#define MAX_INDEXES     8                   /* Max no. supported          */
#define MSG_NO_TABLE    "No table in use"
#define PIC_CAPS        "@!"
#define PIC_DATE        "@D"
#define PIC_DIGITS      "@9"


/*
  Colour definitions for SYSCOLOR(), which uses SYS settings
  if SYS is open, otherwise uses its own defaults.
 */

#define AACLR_NORMAL      1                 /* "Normal" screen output     */
#define AACLR_GET         2                 /* GETs                       */
#define AACLR_PROMPT      3                 /* Prompts                    */
#define AACLR_HMENU       4                 /* Horizontal litebar menus   */
#define AACLR_PULLDOWN    5                 /* Pulldowns                  */
#define AACLR_POPUP       6                 /* Popup boxes                */
#define AACLR_VMENU       7                 /* Vertical menus             */
#define AACLR_POPGET      8                 /* Popup GETs                 */
#define AACLR_DIALOG      9                 /* Dialog boxes               */
#define AACLR_HEADER     10                 /* Window headers             */
#define AACLR_SIGNON     11                 /* Sign on/off                */
#define AACLR_BROWSE     12                 /* Browse windows             */
#define AACLR_STATLINE   13                 /* Status line                */


/*
  Artful v1.xx functions now included in Clipper 5.0
    ALLTRIM()
*/


/*
  Artful v1.xx functions lost because of uselessness/redundancy
    IS_TYPE()
    UN_DEF()
 */



/*
  Backward compatibility
 */

#translate AINDEX( <foo> )    =>   XCOUNT( <foo> )
#translate MEMO_POS( <foo> )  =>   MEMOPOS( <foo> )
#translate MSTATUS( <foo> )   =>   MEMOSTATUS( <foo> )
#define LPAD( foo, n )             PADL( foo, n )
#define PAD( foo, n )              PADR( foo, n )
#define RDUPE()                    GET_STD2( 3 )
#define UN_DEF( foo )              ( TYPE( foo ) $ "UE" )



/*
  Standard Date Format
 */

#define AABOY( foo )        "01/01/" + foo
#define AADATEFORMAT()      IF( __SetCentury(), "mm/dd/yyyy", "mm/dd/yy" )
#define AAEOY( foo )        "12/31/" + foo


/*
  Pseudofunctions, many of them replacing Artful v1.xx functions
 */

#define AACURPATH()           CHR( CURDRIV() ) + ":\" + CURDIR( CHR( CURDRIV()))
#define AAEXECUTE( foo )      IF( VALTYPE( foo ) == "B", ;
                                  EVAL( foo ), MACRO( foo ))

/* R103 #translates FILE() if we #translate FILENAME(). Yikes! */
#translate AAFILENAME( <foo> )  => ;
           SUBSTR( <foo>, MAX( 1 + RAT( ':', <foo> ), 1 + RAT( '\', <foo> )))

#translate AAFULLPATH( <dir>, <fil> )  =>  ;
           ALLTRIM( <dir> ) + IF( EMPTY( <dir> ), ;
                                  "", ;
                                  IF( RIGHT( <dir>, 1 ) $ '\:', "", '\' ) ;
                                ) + ;
           ALLTRIM( <fil> )

#define AAVG( foo )           ( ASUM( foo ) / LEN( foo ) )
#define AEMPTY( foo )         ASCAN( foo, ;
                                     { | x | IF( x == NIL, .T., EMPTY( x ) ) } )
#define AFULL( foo )          EVAL( { | x | IF( x == 0, LEN( foo ), x - 1 ) }, ;
                                    ASCAN( foo, { | y | y == NIL } ) )
#define CASE_OF( foo, _a1, _a2 ) ;
        EVAL( { | x | IF( x > 0, _a2[ x ], "" ) }, ASCAN( foo, _a1 ) )
#define CHG_MONS( _date, _mons ) ;
        ( _date + ( 30.44 * (_mons) ) )
#define CONFIGURE()           THE_USUAL( "SYS" )
#define CRLF( foo )           foo + CHR( 13 ) + CHR( 10 )
#define DESKTOP()             @ 0, 0, 23, 79 BOX "#########"

#translate DBF_EXIST( <foo> )  =>   ;
           FILEFOUND( TRIM( <foo> ) + IF( "." $ <foo>, "", ".DBF" ) )

#translate DBF_NAME( <foo> )   =>   ;
           TRIM( <foo> ) + IF( "." $ <foo>, "", ".DBF" )

#define FIELD_NO( foo )       ASCAN( DBSTRUCT(), { |x| x[1] == UPPER( foo ) } )
#define FIRSTCAP( foo )       ( "!" + REPL( "X", LEN( foo ) - 1 ) )

#define FV( p, r, y, t )      ( (p) * ( ( 1 + (r) / (y) / 100 )  (t) ) )
#define IS_ARRAY( foo )       ( VALTYPE( foo ) == "A" )
#define IS_BTW( foo, lo, hi ) ( foo >= lo .AND. foo <= hi )
#define IS_CHAR( foo )        ( VALTYPE( foo ) == "C" )
#define IS_COLOR()            ( IF( !ISCOLOR(), .F., ;
                                  IF( TYPE( "monochrome" ) != "L", .T., ;
                                             !monochrome )))
#define IS_DATA( foo )        ( foo >= 32 .AND. foo <= 253 )
#define IS_DATE( foo )        ( VALTYPE( foo ) = "D" )
#define IS_DEF( foo )         !( TYPE( foo ) $ "UE" )
#define IS_DIGIT( foo )       ISDIGIT( foo )
#define IS_DIR( foo )         FILE( IF( "" == foo, "", ;
                                        IF( RIGHT( foo, 1 ) $ ":\", ;
                                            foo, foo + "\" ) + "nul" ))
#define IS_EVEN( foo )        ( MOD( foo, 2 ) == 0 )
#define IS_FIELD( foo )       ( FIELDBLOCK( foo ) != NIL )
#define IS_INT( foo )         ( foo == INT( foo ) )
#define IS_LINKED( foo )      ( TYPE( LEFT( foo, AT("(",foo) ) + ")" ) == "UI" )
#define IS_LOGIC( foo )       ( VALTYPE( foo ) == "L" )
#define IS_MEMO( foo )        ( VALTYPE( foo ) == "M" )
#define IS_NUM( foo )         ( VALTYPE( foo ) == "N" )
#define IS_ODD( foo )         ( MOD( foo, 2 ) == 1 )
#define IS_OPEN( foo )        ( SELECT( foo ) > 0 )
#define IS_TIME( foo )        ( VAL( LEFT( foo, 2 ) ) < 24 .AND. ;
                                VAL( SUBSTR( foo, 4, 2 ) ) < 60 .AND. ;
                                VAL( RIGHT( foo, 2 ) ) < 60 )
#define IS_VIRTUAL( foo )     ( FIELDBLOCK( foo ) == NIL )
#define MACROBLOCK( foo )     &( "{||" + TRIM( foo ) + "}" )
#define MOD( n1, n2 )         IF( n2 == 0, n1, ( (n1) % (n2) ) + ;
                                  IF( ( (n1) % (n2) ) * n2 < 0, n2, 0 ) )
#define PMT( p, r, y )        ( ( (p) * ( (r) / 1200 ) ) / ;
                                ( 1 - ( (r) / 1200 + 1 )  ( (y) * -12 ) ) )

#translate ROOTNAME( <foo> )  => ;
           IF( "." $ <foo>, LEFT( <foo>, RAT( ".", <foo> ) - 1 ), <foo> )

#define QUERIES()             THE_USUAL( "UQUERY" )
#define SSN( foo )            TRANSFORM( foo, "@R ###-##-####" )
#define SSNC( foo )           TRANSFORM( foo, "@R ### ### ###" )
#define STOT( foo ) ;
        EVAL( { |x| STRZERO( INT( MOD( x / 3600, 24 ) ), 2, 0 ) + ':' + ;
                    STRZERO( INT( MOD( x / 60, 60 ) ), 2, 0 ) + ':' + ;
                    STRZERO( INT( MOD( x , 60 ) ), 2, 0 ) }, MOD( foo, 86400 ) )
#define STRINT( foo )         LTRIM( STR( INT( foo )))
#define TTOS( foo )           ( VAL( LEFT( foo, 2 ) ) * 3600  + ;
                                VAL( SUBSTR( foo, 4, 2 ) ) * 60    + ;
                                VAL( RIGHT( foo, 2 ) ) )
#define USTATS()              THE_USUAL( "DSTATS" )


/*
  Array indexes for THE_USUAL()'s codeblock array of user functions
 */

#define UDF_SCR  1
#define UDF_SAY  2
#define UDF_KEY  3
#define UDF_FLD  4
#define UDF_RPL  5

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson