
Examples
Example 1 (writes "Hello world!" in a clean window, afterwards it gives a beep and asks for a keyboard hit).
$cls @Hello world! $snd @Press a key. . . $key
Example 2 (Open a file, validate it, modifie it, close it and say bye).
+RUNME.EXE =7430 >0000:0010 '9090 - @File is changed!
Example 3 (Check the filesize, verifies some data, change some attributes and patch the file)
; ; Heck IO.SYS ; @Checking system file(s) ; Go to the file position. $sbd $cdr:\ !IO.SYS:223148 ; Since we're still here the filesize is oke. ; Let's change the IO.SYS &rhs:IO.SYS +IO.SYS ; Check for characters '95', because we don't want to heck again. >0000:F32B =39 >0000:F32C =35 ; Since we're still here the file is unmodified. >0000:F323 "OS/2 Warp! - &RHS:IO.SYS @System file(s) seem to be oke! ; ; Have a nice day :-) ;
Example 4 (Create a file using variables)
; ; Create a file ; @Enter filename: ?FileName @ @Enter first line: ?Line1 @ @Enter second line: ?Line2 @ ; ; Create the file ; #%FileName% "%Line1% . "%Line2% . - @File is created! ;
Example 5 (Building some loops)
;
; Loop de loop
;
@Start
$rep:4
{
@Hello:
$rep:4
{
@world!
}
}
@End
;
Example 6 (Case structure)
;
$cls
@
@-= Main menu =-
@
$case
{
1. Option one;
{
@Option 1 choosen.
$snd
@Press a key...
$key
$exit:1
}
2. Option two;
{
@Option 2 choosen.
$snd
@Press a key...
$key
$exit:2
}
3. Option three.
{
@Option 3 choosen.
}
}
@
@Thanks for using this program!
@
;
Well, in the above example the user sees the following screen:
-= Main menu =-
1. Option one;
2. Option two;
3. Option three.
Enter choice:
PCOM will use the 1, 2 and 3 as input keys. If you use an A remeber
that an a and an A have different values. You can use a $cap:off first.
By pressing a '1' the users gets the message 'Option 1 choosen.' and after
a keypress the program will quit using ERRORLEVEL 1. If you are not using
the $exit command, like option 3, the program will continue after the case.
So if the user presses a '3' there will be a 'Option three choosen.' message
and a 'Thanks for using this program!' message. If any other key is pressed
there will be a 'Thanks for using this program!' message. If you like the
user to use the input keys only you can create something like the following:
;
$case
{
1) Infinite life;
{
...(a patch here)...
$exit:0
}
2) Infinite armour.
{
...(a patch here)...
$exit:0
}
}
@Invalid input!
$snd
$exit:1
;
The program sends a message after an incorrect key is pressed. The $case command can not be nested, but there can be more then one $case commands in a single source.
Example 7 (How to use the arguments).
; @Enter Your Name Utility v1.0 @ $var:%Arg%>? $arc:Use: EYNU <your name> $arg:%Arg% ; Write it to screen: @~!:Thanks: @%Arg% ; Write it into a file: #EYNU.TXT . "%Arg% . - ;
Example 8 (How to use the errorhandler routine).
;
$on_err
{
$snd
@
@Wow, an error did occure!
@Smash the keyboard. . .
$key
}
+12345678.123
-
;
The routine will be called when one of the following commands get's an error:
Example 9 (How to use $run with variables).
; Plot some screen mess and check arguments @New File v1.0 @ $var:%Arg%>? $arc:Use: NF <filename> $arg:%Arg% ; Oke, we are still here, so do the job ; We are going to create the complete commandline as follows: ; - Create var using NOTEPAD.EXE in the %Command%-variable; ; - Add space behind NOTEPAD in the %Command%-variable; ; - Add filename, used argument, behind %Command%-variable. ; ; %Command% contense when NF TEST.TXT is typed: NOTEPAD TEST.TXT. ; $var:%Command%>NOTEPAD.EXE $vbc:%Add%>20 $vct:%Add%>%Command% $vct:%Arg%>%Command% $run:%Command% ;The above example simulates the following commandline: $RUN: NOTEPAD.EXE %Variable%.