J.M.K SOFTWARE FACTORY International J.M.K S.F. ÛÛÛÛÛÛÛÛÛÛÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛÛÛÛÛÛÛÛÛÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ± ÛÛ±ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ÛÛ±apid ÛÛ±ÄÄB A T C HÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ J.M.K S.F. RapidBATCH PL¸ 1.1.1 - Freeware Edition - PROGRAMMING-MANUAL ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» º J.M.K S.F. RapidBATCH¸ PL 1.1 Freeware Edition ¸ 2001 by J.M.K S.F. º º The easy DOS, Windows and Linux Script Programming Language º ÌÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄĹ º PROGRAMMING MANUAL º ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ Contends Introducion 1 Programming in the J.M.K S.F. RapidBATCH scripting language 2 The first program 2.1 Execute a program 2.1.1 Compile a program 2.1.2 Variables 2.2 Declaration of variables 2.2.1 Input and output data 2.2.2 Work on variables 2.2.3 Jumps in the program 2.3 Complex programming 2.4 Shellcommands 2.5 Set cursor and colors 2.6 1. Introducion -=-=-=-=-=- J.M.K S.F. RapidBATCH PL is a complete new, on no other programming language based, from the German company J.M.K S.F. designed programming language for development of batch-likely, small computer programs. The programming lan- guage comes directly with a interpreter to test and run programs instant as soon as with a fast compilersystem, which can create stand-alone .EXE pro- grams, that don't need any runtime modules or something like that. The programming language is in the presented Freeware Edition a complete deve- lopment system. J.M.K S.F. RapidBATCH PL was developed for PC profis and de- velopers just as for "normal" PC users, hobby programmers and people who wants to develop just some computer programs! With only 20 programming instructions is the programming language very slim for experienced developers, however with that 20 instructions you can already do much things. Also for your "old" Batch-programs, the programming language is very helpfull: The included "Bat2Rb Compiler" is able to compile Batch programs in the code of the J.M.K S.F. RapidBATCH¸ programming language. Then you can compile them to stand-alone .EXE programs. Then they are saved against unauthorized changes, and you can give them to each other. Unique: With the Freeware Edition you can, if you had registered you for free at J.M.K S.F., you can pass you programs along and you can sell them!! Additi- onal you can then update cheaply on other programming languages and products from J.M.K S.F.. 2. Programming in the J.M.K S.F. RapidBATCH scripting language -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- The J.M.K S.F. RapidBATCH programming language is very simple obliged - you can develop just programs which outrun the batch-niveau - and from there not very efficient for big programs, but very useful to automate actions or to write some tools. In this manual, the development of some programs in this simple script programming language will be depicted. 2.1 The first program -=-=-=-=-=-=-=-=- The first program that we will write, will be very easy. It should output only the text "This program was written by me!" on the screen. First it should clear the screen contend. Then it will output te text, and af- ter that, the user should press a key of his choice. Please run now a ASCII text editor of you choice (e.g. Notepad or Edit). I re- commend edit.com from DOS to edit programs. But that's your choice. Please input the following code: Cls. EchoLn This program was written by me! Pause. End That will be the first program. Save it under the filename first.rb, and exit the editor. J.M.K S.F. RapidBATCH PL programming instructions are resemble with the batch commands at the first look. But that's perfect wrong, because you can do with every command more than in batch. For example, you can set the background color with the Cls-instruction directly without the Back-instruction! This instruction will clear the screen in blue: Cls 1 Now to the instructions: The Cls-instruction clears - as already said - the screen contend. The dot (.) after Cls said, that there will not be used a definitive color. Normally it will be the color black. EchoLn is the textout- put instruction. It was derived from the batch command Echo. ECHO LiNe means, that the line will break after the text output. The instruction Echo - like the command from batch - means, that the line will not break after text out- put. The Echo-instruction will be used for in-text variable outputs and to output text before user prompts. The following text will not be written in any special chars, which marks end and begin of the text, but it will be written directly. The PAUSE-instruction waits, without additional paramters, until the user had pressed a key. You can also write e.g. Pause 4. Then the program will wait four seconds. Here is also valid: Parameters, apart from variables, will be written without special chars. The dot (.) behind Pause sais here, that the program should wait until a key is pressed. The End-instruction says the interpreter or compiler that the program had sto- pped. If you forget END, you will recive a error message. So, now you had learned enought about the first instructions, now you will see that the program really runs!! 2.1.1 Execute programs -=-=-=-=-=-=-=-= To run programs in the simplest and fastest way, you should use the interpre- ter. The interpreter executes every program line without compilation. If you work in DOS, you enter, if you be in the install directory of J.M.K S.F. RapidBATCH PL and you will run the program first.rb, the following: rbi first.rb Under windows you must only drop the file first.rb on the program icon of rbi.exe. Then you will see a complete black screen with the text "This program was wri- tten by me!". Congratulations, that's you first running program written in J.M.K S.F. RapidBATCH PL!! Press a key of your choice, and it will exit soon. 2.1.2 Compile programs -=-=-=-=-=-=-=-= The delivered compilersystem compiles RapidBATCH-Programs into stand-alone .EXE-programs running in DOS and a Windows DOS-Box. A compilersystem is mostly a compiler and a linker, which work together, to generate a program. If you work under real DOS, enter rbc first.rb on the DOS prompt to compile the program first.rb. The compiler runs automati- cally the linker plink.exe, which links the Compiled Object Code .COC file to a .EXE program. Under Windows you must use the batch-file rbc_win.bat, because the compiler has problems to find some files under Windows. The batch program fixes that bug. But you can also use rbc_win.bat under real DOS without errors. While compiling, you can see the compiling status. First the compiler checks the syntax and compiles the code to runtime machine code. The the linker runs, which will link the runtime-library with the object code in stand-alone .EXE's. Now you can drop your programs to another directory, or you can give it to friends or you can sell it. Who will not have just a cool program *grinch* ;-)! 2.2 Variables -=-=-=-=- Variables are adresses in the memory, which can contain different values. Other programming languages use different variabletypes like integer, long integer, double, string, etc., but J.M.K S.F. RapidBATCH¸ PL knows only one type, the string type. But J.M.K S.F. RapidBATCH¸ PL is also able to calculate variable-contends, if they include a numerical value. Yeah, now you will know for what variables are good! Well, assume the user should enter his name at a prompt. the data he enters will be saved in a given variable, which the programmer had defined before. Now the contend of the variable, the name of the user, can be requested in ev- ery part of the program. Also you can, if the variable includes a numerical value, compute it or you can work with the contend. The value of a variable is variabel (what else?!), and the value of the variable can influence program's drain. 2.2.1 Declare variables -=-=-=-=-=-=-=-=- If you want to use variables in the program, you had to declare them first. The variable must be declared, because that, the program know which variable exists. For this purpose you must use the instruction DEC (DEClare). After the Dec instruction, the names of the variables, if they're more than one, cutted by a comma (,), will be given. Variablenames will be surrounded by angular brackets ([]) in the J.M.K S.F. RapidBATCH scripting language, like: [variable-name] 'Variable-name' can be - different to other programming languages - a arbitra- ry name. The name [02_abcd_yeah!!] is also so correct like [this is a varia- ble, that contains a phrase], but names over 255 chars are forbidden. Not all- owed is: [this is a [error] name], because the interpreter or compiler thinks that the name is [this is a [error]! J.M.K S.F. RapidBATCH PL knwos only one varible type, with that you can calu- late or work strings as soon as numerical values. The memory size is variabel. In the following program we will declare the three variables [test], [message] and [end]. Nothing else will happen: Dec [test],[message],[end] End Here the program was said that you will use three variables in you program. Please pay attention to the dense syntax formulation in every, own programming language created by the company J.M.K S.F.! The phrase Dec [test], [message], [end] will be a error for the compiler as soon as the interpreter. You will get a Syntax-Error message. Please write then Dec [test],[message],[end] to jump over such messages. This error will be fixed soon. 2.2.2 Input and output data -=-=-=-=-=-=-=-=-=-=- Unaffected it will be senseless, if you could only declare variables and no- thing else! So now we write some programs to get data from the user or from a direct value. If you want to let a variable a direct value, you had to use the instruction Let. in the first program, we will declare the variable [test] and let her the value "Hello!": Dec [test] Let [test]=Hello! End You can also let a variable the value of another variable: Let [test1]=[test2] Will you get data from the user, use the INPUT-instruction: Dec [test] Echo Please enter something: Input [test] Echo You had entered Echo [test] EchoLn at the input-instruction! End Use the instruction Echo, to write text before a input instruction. 2.2.3 Variablen bearbeiten -=-=-=-=-=-=-=-=-=-= Now we will compute and work with variables. First we will calculate two variablevalues to one result. For this purpose, we use the function CALCVAR. CalcVar calucates variables with a numerical contend or direct given values. You can use the calculation operations addition (+), subtraction (-), multiplycation (*) and division (/). The following program represents a coinage calculator from german DM to euro- pean EURO: Dec [DM],[EUR] EchoLn DM ---> EURO Calculator Echo Please input DM sum: Input [DM] CalcVar [EUR]=[DM]*'0.51' Echo Euro sum: EchoLn [EUR] End Here the variable [DM] will be multiplied with the value 0.51, and the result will given to the variable [EUR]. Here we have a problem, which we will fix in the chapter "complex program" of this programming book. You can compute so much values and variables with the CalcVar-instruction like you want! Pay attention: Direct values must be written here in high commas, like '12', for example. Also don't insert spaces! The following instruction will activate a syntax error: CalcVar [hello] = [test] * '45' + [hello] Please write here: CalcVar [hello]=[test]*'45'+[hello] to get no compiler error. Also, constructions like CalcVar [test]=[test]*'45'+[hallo]/'45'*'38'-[var12]/'102'/'45'*'38'-[var29] are possible! While the compiling process, such constructions will be proofed if they are right. The compiler will detect such errors like CalcVar [hello]=[test]*45'+[hello] immediatelly. Note that you had to give a declared variable-name before the result sign!! The second function to manipulate variables is called LINKVAR. It interlinks variables and direct values to one string. You can handle it liek the CalcVar instruction, but allowed are only additional signs (+). To depicit the instru- ction, here a example program: Dec [name],[ergebnis] Echo Enter your name: Input [name] LinkVar [ergebnis]='The name '+[name]+' is really cool!!' EchoLn [ergebnis] End Here the variable [name] is interlinked with two direct values. The program is similar to Dec [name] Echo Enter your name: Input [name] Echo The Name Echo [name] EchoLn is really cool! End Please note the special rules like at the CalcVar-Instruction. 2.3 Jumps in the program -=-=-=-=-=-=-=-=-=-= Like in all, good programming languages, you can jump to jump marks in your programs. Here an endless program. Dec [i] %again CalcVar [i]=[i]+'1' EchoLn [i] Goto again End The GOTO-instruction jumps here to the jump makr %again. Jump marks will be marked in the program by a percent sign (%). Behind the Goto instruction, the mark name is given by without percent sign. You can use every name as a jump- mark name. 2.4 Complex programs -=-=-=-=-=-=-=-= Until now we had written programs, which are running from the beginning to the end. But such programs are mostly boring. But here helps the IF instruction! It offers programs to hit conditions. We open the EURO calculator a second time. Here we have a very unnice problem: What's if the user enters 0? The interpreter and the compiled programs output 0 as result but this is only a example. The following program jumps to the jump mark %error, if user enters 0: Dec [DM],[EUR] %again Echo Please input DM sum: Input [DM] If [DM]='0' Goto error CalcVar [EUR]=[DM]/'0.51' Echo Euro result: EchoLn [EUR] Halt %error EchoLn 0 is not allowed! Goto %again End Here If profes, if [DM] contends the value 0. If the result of the comparison is TRUE, the program jumps to %error. Else it runs forth. An ELSE-Instruction don't exist in J.M.K S.F. RapidBATCH PL. The HALT-instruction means, that the program should exit here. We can now extend the calculator to a little menu: Dec [DM],[EUR] %again Echo Please input DM sum: Input [DM] If [DM]='0' Goto error CalcVar [EUR]=[DM]/'0.51' Echo Euro result: EchoLn [EUR] Echo Make new calculation (Y/N) Input [menu] If [menu]='Y' Goto %again Halt %error EchoLn Division durch 0 nicht m”glich! Goto %again End Here will be proofed, if the user had entered Y for "Yes". Also it exists a IF NOT-instruction: Echo Neue Berechnung durchf�hren? (J/N) Input [menu] If Not [menu]='N' Goto %nochmal Halt Here will be proofed if [menu] contends NOT 'N' for "No"! 2.5 Shellcommands -=-=-=-=-=-=- Do you want to run a DOS-command, which is very important for batch programm- ing. Here you can use the SHELL instruction. An example: EchoLn All .EXE-Programs in this directory: EchoLn. Shell dir *.exe End Also you can use variables: Dec [onshell] Echo Please input shell command: Input [onshell] Shell [onshell] EchoLn Ready! End Ort direct to the DOS section: EchoLn Enter EXIT to exit ;-)... EchoLn. Shell. EchoLn ...I'm there! End 2.6 Set cursors and colors -=-=-=-=-=-=-=-=-=-=-= It's also possible the screen colors. For that you can use the instructions BACK and TEXT. The Back-instruction is responsible for the background colors, the Text-instruction for the foreground (Text). The following program outputs the Text "That's all folks!" in red fore- on blue background colors: The color-values (Here: 4 red, 1 blue) can you get from the color table in the reference. Back 1 Text 4 EchoLn That's all folks! End Also here you can use variables: Dec [text],[back] Let [back]=1 Let [text]=4 Back [back] Text [text] EchoLn That's all folks! End You can also set with the instructions XCur and YCur the text cursor to a ar- bitrary position. The screen has a lenght from (X axle) of 79 chars and 24 lines (Y axle). The maximal value for XCur is therewith 79, for YCur 24. The following program outputs "Yeah!" on position X: 12 Y: 4. YCur 4 XCur 12 EchoLn Yeah! End You can also use variables in this instructions. To get detailed informations to all instructions, please look in the language reference!