Miscellaneous Key Words



CD-TRAY-EJECT: <drv_letter>
CD-TRAY-CLOSE: <drv_letter>

Ejects/closes the tray of a specified CD-ROM drive.

See also: WatchDrive: <drv_letter>, WatchDriveRemove: <drv_letter>, IS-CD-PRESENT: <drv_letter>


IS-CD-PRESENT: <drv_letter>

Returns TRUE (-1) if there is a disk in the specified CD-ROM drive and returns FALSE (0) if the specified CD-ROM drive is empty.

Example:

#( test_cd_present
WatchShutdown Action: IS-CD-PRESENT: "d" IF ERR-MSG: "Remove disk from CD-ROM drive!" THEN )#

There also exists a postfix version of this word. To be used at run-time (in console, for example):

CHAR D IS-CD-PRESENT

To be used at compile-time (when defining tasks in your crontabs):

[CHAR] D IS-CD-PRESENT

See also: WatchDrive: <drv_letter>, WatchDriveRemove: <drv_letter>, CD-TRAY-EJECT: <drv_letter>, CD-TRAY-CLOSE: <drv_letter>


PAUSE: <time_in_ms>
PAUSE: <hh:mm>

Suspends a task for a specified length of time.

Examples:

#( test_pause
Time: 30 7 * * * *
Action:
    START-APP: d:\tools\vmtdial\vmtdial.exe -h
\ waiting for three seconds PAUSE: 3000 WIN-CLOSE: "*VMT Dialer*" )#
#( test_pause1 WatchFile: "c:\xxx.sem" Action: PAUSE: "00:30" \ ... executing the job 30 minutes after the flag file was spotted )#

Word PAUSE can also be used in with postfix-type notation (i.e. "<time_in_ms> PAUSE" ), but in this case time may be specified only in milliseconds.

Example:

\ a pause five seconds long
5000 PAUSE
\ a pause  one minute long
60000 PAUSE

NAME2SIDS ( a u -- a u )

Receives a string with a user name as an argument and convert it into a SID string (Security Identifier: a unique number identifying a user or a user group). This word can be used in example to access the user's branches in subtree HKEY_USERS of Windows registry.

S" VKondakoff" NAME2SIDS

The word NAME2SIDS should be used in Win2000/XP.


LOG: "filename" "message"

Appends contents of message into the log file specified in filename.

There also exists a postfix version of this word:

S" message" S" filename" LOG

S" message" CRON-LOG

Writes the message into the cronlog specified in variable Cronlog: in nncron.ini. The string passed as a parameter to word CRON-LOG may contain nnCron's predefined variables.

Example:

S" test message" CRON-LOG
S" message from %USERNAME%" CRON-LOG

CLIPBOARD: "text"

Places the contents of argument text in the clipboard.

There also exists a postfix version of this word:

S" text" CLIPBOARD!

See also: CLIPBOARD, WatchClipboard:


FREE-SPACE: <drv_letter>

Returns the amount of free space (in kilobytes) on a specified drive.

Example:

\ returns "TRUE" if  C: drive has 
\ less then 10 megabyte free space
\ and "FALSE" if C: drive has more 
\ then 10 megabyte free space
FREE-SPACE: C 10000 < 

There also exists a postfix version of this word:

\ for use in console:
CHAR <drv_letter> FREE-SPACE
\ for use in crontabs:
[CHAR] <drv_letter> FREE-SPACE
\ or
%CHAR <drv_letter> FREE-SPACE%

HIDE-ICON
SHOW-ICON

These key words, respectively, hide nnCron icon in system tray if it is visible and show the icon if it is hidden

HIDE-ICON is executed after a certain delay.


CUR-TASK-NAME ( -- a u )

When used within a tasks definition, this word returns the name of the current task.

Example:

#( test_taskname
NoActive
Action:
    MSG: "Current task name: %CUR-TASK-NAME%"
)#

DISABLE-CRON
ENABLE-CRON

Word DISABLE-CRON switches nnCron to suspended mode. Word ENABLE-CRON, does the opposite thing: it causes nnCron to return to the normal operation mode.

It is important to note that while nnCron is in suspended mode, the task which suspended nnCron still remains active (as well as tasks with HyperActive option). This allows you to wake up nnCron programmatically from the same task.

Example:

#( test_suspend
\ when flag file "disable.flg" appears, 
\ we'll switch nnCron to suspended mode for 10 minutes
WatchFile: "C:\TEMP\disable.flg"
Action:
    BEEP: 250 500
    DISABLE-CRON
    PAUSE: 00:10
    ENABLE-CRON
)# 

DISABLE-CRON?

Returns TRUE (-1) if nnCron is in suspended mode, and returns FALSE (0) if nnCron is in normal mode. For example, you could use this word to start a task only if nnCron is in suspended mode.

Example:

#( test_suspend?
RunOnce NoDel HyperActive Rule: DISABLE-CRON? Action: MSG: "nnCron is disabled!" )#

GetLastError

This word is calling Win32 API GetLastError() function. If there was an error during execution of last command, it returns the error number, and if there was no error, it returns 0.

Word GetLastError can be used with following key words: START-APP:, START-APPW:, FILE-CREATE ( -COPY, -MOVE, -RENAME, -CROP, -WRITE, -APPEND), DIR-CREATE (-DELETE) etc.

Example:

#( test_error
NoActive
Action:
    FILE-DELETE: "c:\xxx\test.sem"
    GetLastError
    IF MSG: "FILE-DELETE error: %GetLastError%" THEN
)#

GetLastError shouldn't be used with word FILE-DELETE: (details).


RANDOM ( range -- random )

This postfix word generates random numbers using an implementation of the function RAN4, described in the second edition of "Numerical Recipes in C". This word takes a number as its argument, that sets an upper limit for random numbers. The random numbers will range from 0 to the argument value - 1. So, if you call RANDOM with an argument 1000, the random numbers will range from 0 to 999.

Random numbers generator is initialized with a special word START-SEQUENCE ( dcounter dseq# ), that takes two double length arguments. The top of stack specifies which sequence to generate numbers from. The second on stack specifies the starting position within that sequence. When launching a task, unique values are automatically assigned to these arguments, but you can assign them manually, by using, for example, the number of milliseconds since startup of operating system (GetTickCount):

GetTickCount DUP 2DUP START-SEQUENCE

Examples:

\ random numbers will range from 0 to 510
511 RANDOM

#( test_random
WatchHotKey: "${F5}"
Action:
    \ START-SEQUENCE was set automatically 
    \ displaying random number (range from 0 to 99) in a message:
    MSG: "Random: %100 RANDOM%"
    \ printing random number (range from 0 to 99) to console:
    100 RANDOM . CR
)#

#( test_random_manual
WatchHotKey: "${F6}"
Action:
    \ setting START-SEQUENCE manually
    GetTickCount DUP 2DUP START-SEQUENCE
    \ displaying random number (range from 0 to 99) in a message:
    MSG: "Random: %100 RANDOM%"
    \ printing random number (range from 0 to 99) to console:
    100 RANDOM . CR
)#

RES ( n -- a u )

This posrfix word uses a number as its argument and returns a corresponding string from active language resource file (see also: Language:).

Example:

#( test_predefined_string
NoActive
Action:
    \ displaying 'Buy nnCron Now!' string in your language
    MSG: "%19 RES%"
)#

#( test_predefined_string1
NoActive
Action:
    \ dislaying full name of a current weekday
    MSG: "%159 WDay@ + RES%"
)#

RunMissed?

Returns TRUE (-1) if the started task was missed and is started 'at the first opportunity' and returns FALSE (0) if the task was started at the scheduled time. You can use the RunMissed? word to display a warning when launching missed task.

Example:

#( test_runmissed
Time: 0 0
Rule: RunMissed? IF TQUERY: "Missed task. Launch it?" 5 Yes ELSE 1 THEN
Action:
    \ ...
)#

TRAY-REFRESH

Refreshes system tray and removes "lost" icons, which can remain in system tray after the application was closed from nnCron.

Example:

#( test_close_miranda
NoActive
Action:
    PROC-CLOSE: "miranda32.exe"
    TRAY-REFRESH
)#

WINAPI: <function_name> <dll_name>

This word allows you to import win32-functions from external DLLs to nnCron by specifying function name and the name of dll-file, where the function resides.

WINAPI: MoveFileA KERNEL32.DLL
WINAPI: RasDialDlgA RASDLG.DLL
WINAPI: NetSessionEnum NETAPI32.DLL

During the import the function is converted to a new postfix word, that you can use in all of your tasks. Function arguments are reversed to comply with postfix notation.

Before the import:

your_function(1, 2, "string", 4);

After the import:

4 Z" string" 2 1 your_function

Value, that was returned by imported function stays on the stack. Delete this value if you are not planning to use it in your task.

Example:

#( convert_to_lower_case
NoActive
WINAPI: CharLowerBuffA USER32.DLL
CREATE convert_buf 256 ALLOT
Action:
    S" My TeSt StRiNg" convert_buf PLACE
    MSG: "Not converted: %convert_buf COUNT%"
    convert_buf COUNT SWAP CharLowerBuffA DROP
    MSG: "Converted: %convert_buf COUNT%"
)#

OnBalloonClick

The USER-variable OnBalloonClick "overrides" the value of nncron.ini variable TrayIconBalloonClick: for the current task (and only for the current task). Thus, for current task you can define a specific action, that should be performed when clicking on a BALLOON: hint.

Example:

#( test_balloonclick
NoActive
: my-click 
  \ some useful activity:
  MSG: "You have destroyed my Balloon!"
;
Action:
    ['] my-click OnBalloonClick !
BALLOON: "Test" "Click me!" )#
#( test_balloonclick1 NoActive Action: [NONAME \ more useful activity: BEEP: 50 500 PAUSE: 200 BEEP: 50 500 NONAME] OnBalloonClick !
BALLOON: "New test" "Click me now!" )#