Updated examples
This commit is contained in:
parent
8608bf2392
commit
4edc8c032f
23
README.md
23
README.md
@ -62,22 +62,31 @@ at this moment!
|
|||||||
* `nethttp "<port>" "<forkval>"` -> throws up a web server on <port> in the current working directory,
|
* `nethttp "<port>" "<forkval>"` -> throws up a web server on <port> in the current working directory,
|
||||||
forkval (0 or 1, 0 don't fork into background / 1 do).
|
forkval (0 or 1, 0 don't fork into background / 1 do).
|
||||||
|
|
||||||
|
This will change rapidly as of currently, slidescript is in beavy development! To get the feel of the scripting,
|
||||||
|
the best bet is to take a look at some of the slidescript examples in 'examples/'
|
||||||
|
|
||||||
|
functions.ss -> displays most basic functions
|
||||||
This will change rapidly as of currently, slidescript is in beavy development!
|
net-http.ss -> displays built in http web server
|
||||||
|
net-listen.ss -> displays slidescript's raw listen socket
|
||||||
|
net-toss.ss -> displays the 'client side' networking function.
|
||||||
|
|
||||||
|
|
||||||
Todo list
|
Todo list
|
||||||
-----
|
-----
|
||||||
|
|
||||||
* Add in-script functions
|
This section will obviously expand and adapt to the direction of the language. This is going to change rapidly.
|
||||||
* New static functions
|
|
||||||
* Loops, and if statements
|
|
||||||
|
|
||||||
|
* Add in-script functions
|
||||||
|
* Add script including
|
||||||
|
* Loops, and if statements
|
||||||
|
* More networking function flexibility
|
||||||
|
* File pull / file push functionality
|
||||||
|
|
||||||
Done
|
Done
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
List of finished features, in a rough summary.
|
||||||
|
|
||||||
* Simple syntax checking and error reporting
|
* Simple syntax checking and error reporting
|
||||||
* Up to 32 layer function piping
|
* Up to 32 layer function piping
|
||||||
* Support for linux system calls
|
* Support for linux system calls
|
||||||
@ -91,6 +100,10 @@ Done
|
|||||||
|
|
||||||
Changelog
|
Changelog
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
Changes between version bumps in SlideScript. Hoping to have a lightweight top-down scripting language
|
||||||
|
by V1.0.0 release! From there it will be molding and preserving the art.
|
||||||
|
|
||||||
* V0.4.0
|
* V0.4.0
|
||||||
* Added calc function for floating math equations
|
* Added calc function for floating math equations
|
||||||
* Cleaned up some more syntax handling, as well as bugs
|
* Cleaned up some more syntax handling, as well as bugs
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
# Variables in SS
|
# Variables in SS
|
||||||
ss_filename=file.txt
|
ss_filename=file.txt
|
||||||
ss_stringdata=Data to encrypt and decrypt
|
ss_stringdata=Data to encrypt and decrypt
|
||||||
ss_exec_command=echo SS executing echo from system shell
|
ss_exec_command=uname -a
|
||||||
|
|
||||||
# Printing function in SS
|
# Printing function in SS
|
||||||
print "Welcome to SlideScript!"
|
print "Welcome to SlideScript!"
|
||||||
@ -40,7 +40,7 @@ print "Some content to print, working with '%ss_filename%' today!"
|
|||||||
# holding the first functions output, writes to %ss_filename%; file.txt
|
# holding the first functions output, writes to %ss_filename%; file.txt
|
||||||
### %PIPE% is the output from the first line function, enc
|
### %PIPE% is the output from the first line function, enc
|
||||||
### %PIPE% is always applied when a pipe is used!
|
### %PIPE% is always applied when a pipe is used!
|
||||||
encrypt "%ss_stringdata%" | write "%ss_filename%" "%PIPE%"
|
encode "%ss_stringdata%" | write "%ss_filename%" "%PIPE%"
|
||||||
# You're left with file.txt, lets move on
|
# You're left with file.txt, lets move on
|
||||||
|
|
||||||
# Lets read the file we just created and show how SS handles its
|
# Lets read the file we just created and show how SS handles its
|
||||||
@ -53,9 +53,18 @@ read "%ss_filename%" | decrypt "%PIPE%"
|
|||||||
md5 "%ss_filename%" | write "%ss_filename%.md5" "%PIPE%"
|
md5 "%ss_filename%" | write "%ss_filename%.md5" "%PIPE%"
|
||||||
# Use a pipe, and push the md5 into a text file of file.txt
|
# Use a pipe, and push the md5 into a text file of file.txt
|
||||||
|
|
||||||
|
# You can also stack pipes for whatever tasks you may need
|
||||||
|
# Here's the encrypt function in action, can also be used as encode
|
||||||
|
md5 "%ss_filename%" | encode "%PIPE%" | write "%ss_filename%.md5.enc" "%PIPE%"
|
||||||
|
|
||||||
# Read md5 file
|
# Read md5 file
|
||||||
|
print "%ss_filename%.md5:"
|
||||||
read "%ss_filename%.md5"
|
read "%ss_filename%.md5"
|
||||||
|
|
||||||
|
# Read encrypted md5 file and decrypt using decode alias
|
||||||
|
print "%ss_filename%.md5.enc:"
|
||||||
|
read "%ss_filename%.md5.enc" | decode "%PIPE%"
|
||||||
|
|
||||||
# Delete function, SS can delete files and directories with one function
|
# Delete function, SS can delete files and directories with one function
|
||||||
# NOTE: it is extremely powerful and can wreck your system if used in the
|
# NOTE: it is extremely powerful and can wreck your system if used in the
|
||||||
# wrong way! Proceed with caution, delete "/" WILL send your files to the
|
# wrong way! Proceed with caution, delete "/" WILL send your files to the
|
||||||
@ -64,11 +73,25 @@ read "%ss_filename%.md5"
|
|||||||
# Lets delete the files we've been messing with, no system calls needed
|
# Lets delete the files we've been messing with, no system calls needed
|
||||||
delete "%ss_filename%"
|
delete "%ss_filename%"
|
||||||
delete "%ss_filename%.md5"
|
delete "%ss_filename%.md5"
|
||||||
|
delete "%ss_filename%.md5.enc"
|
||||||
# Gone!
|
# Gone!
|
||||||
|
|
||||||
print("Testing execution functions");
|
print "Playing with some calc..."
|
||||||
sleep 1
|
# calc function, lets do some basic math
|
||||||
|
calc "32 * 1024"
|
||||||
|
# You can pipe calc to do multi layer equations
|
||||||
|
calc "32 * 1024" | calc "%PIPE% * 2"
|
||||||
|
|
||||||
|
# Lets play with some big numbers here!
|
||||||
|
# SlideScript parses its calc functions using floating points, so you can
|
||||||
|
# handle decimal as well
|
||||||
|
calc "1024 * 1024" | calc "%PIPE% * %PIPE%"
|
||||||
|
|
||||||
|
# Decimal
|
||||||
|
print "Here comes the decimal:"
|
||||||
|
calc "46 / 3.4"
|
||||||
|
|
||||||
# Execute function, SS can call unix system calls!
|
# Execute function, SS can call unix system calls!
|
||||||
# Executes the ss_exec_command variable data, 'ls'
|
# Executes the ss_exec_command variable data, 'ls'
|
||||||
|
print "Testing exec function on system"
|
||||||
exec "%ss_exec_command%"
|
exec "%ss_exec_command%"
|
@ -6,11 +6,15 @@
|
|||||||
# * 0 = do not fork to background
|
# * 0 = do not fork to background
|
||||||
# * 1 = fork to background
|
# * 1 = fork to background
|
||||||
|
|
||||||
|
# Daemonize port
|
||||||
port1=8081
|
port1=8081
|
||||||
|
# Forground port
|
||||||
port2=8080
|
port2=8080
|
||||||
|
|
||||||
# Daemonize
|
# Daemonize, run in background
|
||||||
nethttp "%port1%" "1"
|
#nethttp "%port1%" "1"
|
||||||
|
|
||||||
|
# Run in foreground, Ctrl-C to exit ;)
|
||||||
nethttp "%port1%" "0"
|
nethttp "%port1%" "0"
|
||||||
|
|
||||||
print "Server on %port1% still running in the background"
|
print "Server on %port1% still running in the background"
|
||||||
|
@ -102,7 +102,7 @@ char *process_line(char *line)
|
|||||||
if(strtok(NULL, "\"") == NULL)
|
if(strtok(NULL, "\"") == NULL)
|
||||||
syn_error("ss:error:calc missing end quote");
|
syn_error("ss:error:calc missing end quote");
|
||||||
|
|
||||||
expr_return = ss_expr(tok_srch);
|
expr_return = ss_expr(parse_vars(tok_srch));
|
||||||
|
|
||||||
return expr_return;
|
return expr_return;
|
||||||
}
|
}
|
||||||
@ -357,9 +357,10 @@ char *process_line(char *line)
|
|||||||
char *file_content;
|
char *file_content;
|
||||||
FILE* write_file = NULL;
|
FILE* write_file = NULL;
|
||||||
/* strtok to filename of function */
|
/* strtok to filename of function */
|
||||||
|
|
||||||
tok_srch = strtok(NULL, "\"");
|
tok_srch = strtok(NULL, "\"");
|
||||||
if(tok_srch == NULL)
|
//if(tok_srch == NULL)
|
||||||
syn_error("ss:error:write syntax error, requires a file argument in quotes");
|
// syn_error("ss:error:write syntax error, requires a file argument in quotes");
|
||||||
|
|
||||||
/* Check to see if syntax is correct */
|
/* Check to see if syntax is correct */
|
||||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||||
|
@ -39,6 +39,8 @@ void ss_piping(char *string)
|
|||||||
|
|
||||||
char *stringmem;
|
char *stringmem;
|
||||||
|
|
||||||
|
for(int vv = 0; vv < MAX_PIPE_CMDS; vv++) bzero(spipe[vv].command,MAX_STRING_LEN);
|
||||||
|
|
||||||
stringmem = (char *) malloc(strlen(string)+1);
|
stringmem = (char *) malloc(strlen(string)+1);
|
||||||
if(stringmem == NULL) syn_error("ss:error:memory mapping error...");
|
if(stringmem == NULL) syn_error("ss:error:memory mapping error...");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user