Script 2 Batch Compiler

This web page is temporary.

General

Script 2 Batch Compiler is a project aimed at making windows scripting easy and user friendly. It was originally thought of in late November 2010.

Latest svn version
Script 2 Batch Compiler features:
*compensates and walks around glitches and problems batch code has.
*Makes it easier to write and read batch code.
*Adds new functions to the batch language. Such as Arrays and more proper if statements.

How to use

Script 2 Batch Compiler uses a script that resembels PHP script.
Curently the project is webb only but the plan is to move to XLS when the project has come a bit further.
Paste or write a script in the text box and press convert you may need to toogle edit before doing that. Then copy the output to your .bat file and your done.
Since the project currently is in pre alpha state it only runs in FireFox and you will need the firebug add-on for FireFox. Cause of memmory leaks caused by poor memmory manegment from firefox. It is recomended to refresh the page after a couple of convertions.


Variables are identified by the $ sign
Example:
$num1r = 34;
$num_var = $num1r * 23 +4;

code lines are ended with ;

Strings are defined with " NOT '
Escaping " in strings is done with ^"

if and else statements
Example:
if(1==2 || "gh" != "qw" && 1>0){
    echo("if was true");
}else if($num1r >= 34)
    echo("else if was true");
else
{
    echo("else was true");
}

while statements
Example1:
$i = 0; while(10>$i){
    echo("if was true");
    if($i == 5)
        break;
    i++;
}
Example2:
$i = 0; while(10>$i)
    echo(i++);


for statements
Example:
for($i=0;10>$i,$i++){
    echo("if was true");
    if($i == 5)
        break;
}

function defines
Example:
function my_function($a_variable,$one_more)
{
    echo( str_concat("it is a function $_variable has the value of: ",$a_variable) );
    return ($one_more+2,$one_more-3);
}

echo(my_function("awesome",34)[1]); //all user defined functions returns arrays where [0] is the length of the array and [1] is the first output.


Commands

echo($str)
// Prints $str to console. Returns nothing.

str_concat($str0,$str1)
// Returns $str0 and $str1 concated.

sub_str($str,$start,$length)
// Returns sub string of $str, starting att $start ending at $length, $length may be omitted.

get_env_var($str)
// Returns the environment variable named $str.

get_user_input($str)
// Returns user input $str is a optional question.

reg_add($str1,$str2)
// Not DONE.... adds reg key at $str1, options is $str2(open cmd and write reg add /? for more info about options).

reg_delete($str1,$str2)
// Not DONE.... removes reg key at $str1, options is $str2(open cmd and write reg delete /? for more info about options).

reg_query($str1,$str2)
// Not DONE.... get reg key at $str1, options is $str2(open cmd and write reg query /? for more info about options "/v "+"$value_name" is most likely the wanted option).

file_write_line($str1,$str2)
// returns nothing writes $str2 to file $str1.

file_read($str1)
//returns an array with file $str1.

file_append_line($str1,$str2)
// returns nothing appends new line with data $str2 to file $str1.

pause()
// waits fore user to continue.

set_volume($str)
//Returns nothing, sets current working disk to $str example: set_volume("c");

use_lib($str)
// includes library: current librarys is LTA and LTSA both witch are used to read command output and file contents.

dir($filter,$sort,$timetype)
//Returns files or/and directory's in current working directory. Output is in a form of an array. Filter -D only directory's D only files sort after D or N or other sorting type. Timetype defines with time to sort files after(if files are sorted by time):creation = C, last written = W or last access = A

cd($str) //sets or gets the current working directory.

str_pos($hay_stack,$needle,$from) //finds a substring in a string. Starts search at $from witch has the defult value 0. Returns -1 if string was not found

str_pos_last($hay_stack,$needle,$from) //finds a substring in a string like str_pos it but searches backwards. Starts search at $from witch has the defult value 0. Returns -1 if string was not found

pure_line($str) //prints a batch line without processing it.

start($str) //Starts a program or batch file.

file_del($str) //Deletes a file.

dir_del($str) //Deletes a directory.

str_len($str) //Returns the length of the string.

str_replace($str,$replace,$with) //Replaces a sub string in a big string with a substring.

file_copy($from,$fileto) //Copys a file.

file_move($filename,$fileto_filder) //Moves a file.

file_exists($file) //Returns 1 if file exists return 0 if i doesent.

call($file) //calls a executeblefile lite a function.