Updated examples

This commit is contained in:
Pentium44 2021-04-08 03:01:40 -07:00
parent 8608bf2392
commit 4edc8c032f
5 changed files with 57 additions and 14 deletions

View File

@ -62,22 +62,31 @@ at this moment!
* `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).
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/'
This will change rapidly as of currently, slidescript is in beavy development!
functions.ss -> displays most basic functions
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
-----
* Add in-script functions
* New static functions
* Loops, and if statements
This section will obviously expand and adapt to the direction of the language. This is going to change rapidly.
* Add in-script functions
* Add script including
* Loops, and if statements
* More networking function flexibility
* File pull / file push functionality
Done
-----
List of finished features, in a rough summary.
* Simple syntax checking and error reporting
* Up to 32 layer function piping
* Support for linux system calls
@ -91,6 +100,10 @@ Done
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
* Added calc function for floating math equations
* Cleaned up some more syntax handling, as well as bugs

View File

@ -29,7 +29,7 @@
# Variables in SS
ss_filename=file.txt
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
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
### %PIPE% is the output from the first line function, enc
### %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
# 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%"
# 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
print "%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
# 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
@ -64,11 +73,25 @@ read "%ss_filename%.md5"
# Lets delete the files we've been messing with, no system calls needed
delete "%ss_filename%"
delete "%ss_filename%.md5"
delete "%ss_filename%.md5.enc"
# Gone!
print("Testing execution functions");
sleep 1
print "Playing with some calc..."
# 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!
# Executes the ss_exec_command variable data, 'ls'
print "Testing exec function on system"
exec "%ss_exec_command%"

View File

@ -6,11 +6,15 @@
# * 0 = do not fork to background
# * 1 = fork to background
# Daemonize port
port1=8081
# Forground port
port2=8080
# Daemonize
nethttp "%port1%" "1"
# Daemonize, run in background
#nethttp "%port1%" "1"
# Run in foreground, Ctrl-C to exit ;)
nethttp "%port1%" "0"
print "Server on %port1% still running in the background"

View File

@ -102,7 +102,7 @@ char *process_line(char *line)
if(strtok(NULL, "\"") == NULL)
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;
}
@ -357,9 +357,10 @@ char *process_line(char *line)
char *file_content;
FILE* write_file = NULL;
/* strtok to filename of function */
tok_srch = strtok(NULL, "\"");
if(tok_srch == NULL)
syn_error("ss:error:write syntax error, requires a file argument in quotes");
//if(tok_srch == NULL)
// syn_error("ss:error:write syntax error, requires a file argument in quotes");
/* Check to see if syntax is correct */
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)

View File

@ -39,6 +39,8 @@ void ss_piping(char *string)
char *stringmem;
for(int vv = 0; vv < MAX_PIPE_CMDS; vv++) bzero(spipe[vv].command,MAX_STRING_LEN);
stringmem = (char *) malloc(strlen(string)+1);
if(stringmem == NULL) syn_error("ss:error:memory mapping error...");