There are many other useful classes found in the system. Only a few of them are mentioned below.
Time
represent a particular time of day.
aTime := Time now
aTime := Time nowWithMilliseconds
for backward compatibility with GUI and other I/O related interfaces,
the wellknown "Time now
" method returns a time with second resolution.
The time, when asked to print itself, will not print the milliseconds if they are zero.
Thus "Time now printString
" will print as "hh:mm:ss" (as it did for the past 30years).
To get a higher resolution time, use "Time nowWithMilliseconds
",
which includes milliseconds and will also print them.
aTime := Time hours:hours minutes:minutes seconds:seconds
or:
aTime := Time hours:hours minutes:minutes seconds:seconds milliseconds:millis
aTime hour
aTime minutes
aTime seconds
aTime milliseconds
The Time class also provides useful methods to measure the execution time of a block:
and to get the internal (millisecond-)timer's value.
Time millisecondsToRun:[...]
Notice that Time
only represents times within a day - instances do not differenciate between
times of different dates. Use Timestamp
to represent a time at a particular date.
More details are found in the
"Time
class documentation"
and in the
"Timestamp
class documentation".
Typical uses are:
aDate := Date today
aDate := Date day:day month:month year:year
aDate year
aDate month
aDate day
aDate dayOfWeek
aDate dayOfWeekName
aDate dayOfYear
aDate addDays: numDays
aDate daysUntil: anotherDate
aDate daysSince: anotherDate
aDate weekday
aDate weekdayForLanguage:#fr
aDate abbreviatedDayName
aDate abbreviatedDayNameForLanguage:#en
aDate monthName
aDate monthNameForLanguage:#fr
aDate abbreviatedMonthName
aDate abbreviatedMonthNameForLanguage:#de
aDate isLeapYear
aDate dayInWeek
aDate weekInYear
aDate daysInMonth
aDate daysLeftInMonth
More details are found in the
"Date
class documentation".
Notice:
In previous versions, dates were limited to
being greater or equal to 1-jan-1901. This limitation was removed in 6.2.5. Arbitrary dates can now
be constructed and compared. However, for all leap year computations, the gregorial calendar is
used, and no julian conversion is attempted (i.e. the so called "proleptic gregorian calendar" is used).
aTimestamp := Timestamp now
aTimestamp := UtcTimestamp now
aDate := aTimestamp asDate
aTime := aTimestamp asTime
aTime := aTimestamp asLocalTimestamp
aTime := aTimestamp asUtcTimestamp
aTime := aTimestamp asTZTimestamp:utcOffset
aTime := aTimestamp asTZTimestampInZone:'EST'
Timestamp utcOffsetFrom:aString
Timestamp printIso8601FormatOn:aStream
Timestamp printIso8601CompressedOn:aStream
Timestamp
class documentation".
aTimeDuration := timestamp1 - timestamp2
aTimeDuration := 50 milliseconds
aTimeDuration := 5 seconds
aTimeDuration := 12 minutes
aTimeDuration := 3 days
aTimeDuration := Timeduration hours:h minutes:m seconds:s milliseconds:ms
aTimeDuration := TimeDuration toRun: [ ... ]
aTimeDuration + aTimeDuration
aTimeDuration - aTimeDuration
aTimeDuration * aNumber
aTimeDuration / aTimeDuration
aTimeDuration / aNumber
Timeduration
class documentation".
Character
represent printable characters.
The character range is not limited to 8bit; 16bit and even 32 bit characters are possible
(although the windows operating system is limited to 16bit).
Characters are most often used as elements of String
and TwoByteString
;
on their own, they are seldom encountered.
Typical uses are:
codePoint
isDigit
isLetter
isUppercase
asUppercase
asLowercase
More details are found in the
"Character
class documentation".
Point
represent a coordinate in 2D space.
They are most often used in the graphical user interface to represent window positions,
window extents, position of graphical objects etc.
aPoint := Point x:xCoordinate y:yCoordinate
aPoint := xCoordinate @ yCoordinate
xCoordinate := aPoint x
yCoordinate := aPoint y
More details are found in the
"Point
class documentation".
Point
, instances of Rectangle
are used in the
graphical user interface. They represent a rectangular area defined by
an originPoint and a cornerPoint. (the actual internal implementation may be different).
aRectangle := Rectangle origin:originPoint corner:cornerPoint
aRectangle := Rectangle origin:originPoint extent:extentPoint
aRectangle := Rectangle x:originX y:originY width:width height:height
originPoint := aRectangle origin
cornerPoint := aRectangle corner
extentPoint := aRectangle extent
width := aRectangle width
height := aRectangle height
newRectangle := aRectangle intersect:antherRectangle
newRectangle := aRectangle scaledBy:scaleFactor
newRectangle := aRectangle translatedBy:translation
More details are found in the
"Rectangle
class documentation".
True
and False
,
of which each has only one instance: true
and false
respectively.
Conceptionally, conditional evaluation of expressions is implemented by booleans;
however, most control structures are inline coded by the compilers for more performance.
This means, that even though you find the #ifTrue:
and
#ifFalse:
methods in these two classes,
these methods are rarely executed.
More details are found in the
"Boolean
class documentation".
Using blocks, you can create your own control, enumeration and looping constructs.
Typical uses are:
aBoolean ifTrue:[ ... trueBlock ... ] ifFalse:[ ... falseBlock ... ]
[ ... conditionBlock ... ] whileTrue:[ ... loopedBlock ... ]
start to: stop do: [:loopVar | ... loopedBlock ... ]
aCollection do:[:element | ... block executed for each element ... ]
aButton action:[ ... block executed when button is pressed ... ]
More details are found in the
"Block
class documentation".
OperatingSystem
offers low level access to the underlying
OS services. The actual set of implemented messages
depends on the particular OS used.
Time
, FileStream
, Filename
etc.
more to be documented
More details are found in the
"OperatingSystem
class documentation".
Smalltalk
keeps track of all global variables on the system.
Also, it offers many functions for system management, initialization, startup and shutdown.
more to be documented
More details are found in the
"Smalltalk
class documentation".
ObjectMemory
provides access to low level memory management functions.
There are methods to control the behavior of the garbage collector, interrupt handling etc.
more to be documented
More details are found in the
"ObjectMemory
class documentation".
Copyright © 1996 Claus Gittinger Development & Consulting
<info@exept.de>