home *** CD-ROM | disk | FTP | other *** search
- // Counter Class
- // (c) 1997 SmartDesk, Inc., All Rights Reserved
-
-
- FUNCTION CounterDisplay( filename, digits, dir )
- local cntr
- cntr = new( "counter", filename, dir )
- if ( type( cntr ) != "O" )
- return( "" )
- end
- cntr.increment( )
- return( cntr.display( digits ) )
- END
-
-
- CLASS counter
- PUBLIC:
- local filename, value, imagedir
-
- METHOD new( filename, imagedir )
- local hfile
- _apGenerate( )
- if ( type( imagedir ) != "C" )
- ::imagedir = ""
- else
- ::imagedir = imagedir
- end
-
- ::filename = filename
- if ( ! fileExists( ::filename ) )
- hfile = fileCreate( ::filename )
- if ( hfile < 1 )
- errmsg( "CLASS counter", "Unable to create " + ::filename )
- return( 0 )
- end
- fwriteline( hfile, "[COUNTER]" )
- fwriteline( hfile, "val=0" )
- fclose( hfile )
-
- ::value = 0
- else
- ::value = 0 + iniGetString( ::filename, "COUNTER", "val", "0" )
- end
-
- return( 1 )
- END
-
-
- METHOD increment( )
- ::value++
- iniSetString( ::filename, "COUNTER", "val", "" + ::value )
- return( 1 )
- END
-
-
- METHOD display( digits )
-
- local str, valstr, i, image
-
- if ( ( type( digits ) != "N" ) || ( digits < 1 ) )
- digits = 6
- elseif ( digits > 8 )
- digits = 8
- end
-
- valstr = right( "00000000" + ::value, digits )
-
- str = "<table border=0 colspacing=0 cellspacing=0>\r\n"
- str += " <tr><td>\r\n"
-
- for ( i=1; i<=digits; i++ )
-
- image = "cntr" + substr( valstr, i, 1 ) + ".gif"
- str += "<img src=\"" + ::imagedir + image + "\" border=0 width=15 height=20>"
-
- end
- str += "\r\n"
- str += " </td></tr>\r\n"
- str += "</table>\r\n"
-
- return( str )
- END
-
- END
-
-
-
-
-