home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
scripts
/
ckermit
/
string
< prev
next >
Wrap
Text File
|
1999-07-15
|
2KB
|
62 lines
; From: Dat Thuc Nguyen
; Date: Wed Apr 21 11:57:01 1999
; URL: http://www.smalltickle.com
;
; Following is a rudimentary string class based on the Smalltalk model.
;********************************************************
; DEFINITION OF THE STRING CLASS *
;********************************************************
define string {
_assign string::\%1 \%2
_define \%1 {
string.\%1 \v(macro) \%2 \%3 \%4
}
}
;********************************************************
; IMPLEMENTATION OF THE PUBLIC USAGE INTERFACE *
; OF THE STRING CLASS *
;********************************************************
define string.echo {
echo \m(string::\%1)
}
define string.length {
echo \flength(\m(string::\%1))
}
define string.concat {
if define \m(string::\%2) {
_assign string::\%1 \m(string::\%1)\m(string::\%2)
} else {
_assign string::\%1 \m(string::\%1)\%2
}
}
define string.write {
if define \m(string::\%2) {
_assign string::\%2 \m(string::\%1)
} else {
_assign \%2 \m(string::\%1)
}
}
;********************************************************
; USAGE SAMPLES *
;********************************************************
string abc hello ; Create a string abc initialized with 'hello'
abc echo ; Display the string abc
abc length ; Display the length of the string abc
abc write s1 ; Assign the variable s1 with the content of
; the string abc.
echo \m(s1) ; Display the value of the variable s1
string greet _world ; Create a string greet initialized with '_world'
abc concat greet ; Concatenate the string abc with the string greet
abc echo ; Display the string abc
End