Hamster-Scripts: Functions (Hamster): System


HamVersion( <which> )

If used without parameter, it returns the version number of Hamster.

If <which> is given, it returns Hamster version (1), its maintainer (2), its download URL (3) or a comment with "stable" or "beta" (4). Currently unsupported values return an empty string.

Returns: String.

print( "Hamster Vr. " + HamVersion )

HamHscPath, HamHsmPath, HamLogsPath, HamServerPath, HamGroupsPath, HamMailPath, HamNewsOutPath, HamMailsOutPath, HamNewsErrPath, HamStartupPath, HamReportsPath, HamExePath, HamRcPath


Base directory of Hamster, i.e. the path were "HService.exe" is located.


Scripts directory


Script modules directory


Log file directory


Servers directory


Newsgroups directory


Mails directory


News to be posted directory


Mails to be sent directory


Failed posting directory


Startup directory


Reports directory


Directory of "HService.exe"


Scripts directory.

Note: Some are duplicates or do not apply to Classic and are only kept for compatibility with Hamster Classic.

Returns: String with full qualified path-name and trailing backslash.

if( FileExists( HamPath + "Mails\Mail.Out\*.msg" ) )
   # send mails

HamAddLog( <text>, <type> )

Adds the given <text> to the logfile.

<type> can be one of the following codes: 1=Debug, 2=Detail, 3=Info, 4=System, 5=Warning, 6=Error, 7=Status. Any other code will result in 3=Info.

Returns: <text>

HamAddLog( "Hello world!", 1 )

HamRequest( <request>, <request-list>, <reply-list> )
HamRequest( <request>, <request-list> )
HamRequest( <request> )

Sends the given request code <request> with the given parameters (<request-list>) to Hamster's internal "Live" server. The reply-code is returned as function's result, reply-data is returned in <reply-list>.

Both <request-list> and <reply-list> are lists, that were previously allocated by ListAlloc. They can also be given as -1, if no request parameters are needed or no result lines are expected/wanted.

For details on available requests, their parameters and replies see Live Mode of Remote Control Server. Please note, that parameters and results separated by "CRLF" have to be given or are returned as separate lines in the lists.

Returns: -1 on failure, otherwise Live reply code (e. g. 0x4000 on success).

#!load hamrequests.hsm

varset( $lReq, ListAlloc )
varset( $lRep, ListAlloc )
var( $Reply )

$Reply = HamRequest( $LMREQ_COUNTERS_LIST, $lReq, $lRep )
if( $Reply = $LMREP_OK )
   print( "All counters: ", ListGetText( $lRep ) )
   print( "Byte counter: ", ListGetKey( $lRep, "by" ) )
   print( "Request failed! Reply=", hex($Reply) )

ListFree( $lReq )
ListFree( $lRep )

HamRequestStr( <request>, <request-string>, <reply-string-variable> )
HamRequestStr( <request>, <request-string> )
HamRequestStr( <request> )

Same as HamRequest above, but request parameters have to be given as a string (containing any CRLF characters) and reply data is returned as a string in the given variable.

Returns: -1 on failure, otherwise Live reply code (e. g. 0x4000 on success).

#!load hamrequests.hsm

var( $Reply, $ReplyData )

$Reply = HamRequestStr( $LMREQ_COUNTERS_LIST, "", $ReplyData )
if( $Reply = $LMREP_OK )
   print( "All counters: ", $ReplyData )

HamMessage( <message>, <parameter> )
HamMessage( <message> )

Initiates some Hamster-functions, which are normally available and accessed by its menu-items:

<message> <parameter> (default=0) purpose
2 ignored Reset counters and log


0=stop, 1=start Start/Stop local NNTP server
0=stop, 1=start Start/Stop local POP3 server
0=stop, 1=start Start/Stop local SMTP server
Menu: Online/Stop all tasks
100 0=stop, 1=start Start/Stop local RC server

Returns: 0=OK, 1=Failed, 2=Unknown message-number, 3=GPF

HamMessage( 2, 0 ) # reset counters

HamGetStatus( <type>, <item>, <scale> )
HamGetStatus( <type>, <item> )
HamGetStatus( <type> )

Returns current status information of given <type> for given <item> (default 0).

If <scale> is given, the result is divided by this number, e. g. you can give 1024 here to get byte counters in KB or 1024*1024 to get them in MB.

Supported <types>:

<type>=1 Returns 1, if local server is active, 0 otherwise.
<items>: 1=NNTP, 2=POP3, 3=SMTP, 4=Remote Control
<type>=2 Returns the number of currently connected clients.
<items>: 1=NNTP, 2=POP3, 3=SMTP, 4=Remote Control
<type>=3 Returns one of the internal counter values.
<item>: 1=new articles, 2=loaded articles, 3=not loaded (history), 4=not loaded (score file), 5=articles in outbox, 6=new mails, 7=mails in outbox

Returns: >=0: Value, -1: Invalid <type> or <item>, -2: Number too large (use <scale>)

print( HamGetStatus( 2, 1 ) )


Writes unsaved data to disk. Suggested after last article imported with HamArtImport.

Returns: 0


HamSetLogin( <identifier>, <username>, <password> )

Temporarily sets <username> and <password> for the given <identifier>, which can be either the name of a RAS-connection or the name of a news-/mail-server. "Temporarily" means, that this setting is not saved to a file but is kept in memory until Hamster is closed again.

If username and/or password is set to a single question-mark ("?"), Hamster will ask for the value.

Furthermore, one of the stored "general-purpose"-passwords can be selected here to avoid noting it in clear-text in the script.

Returns: 0=OK, <>0=Error

HamSetLogin( "MyProvider", "MyUsername", "MyPassword" )
HamSetLogin( "MyProvider", "MyUsername", "?" )
HamSetLogin( "MyProvider", "$42", "" )

[www.elbiah.de Hamster Playground Documentation]