slidescript/misc/api/basics.html

142 lines
5.6 KiB
HTML

<!DOCTYPE html>
<html lang="en-US">
<head>
<title>SlideScript API: The Basics ~ The Lazy Language</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="SlideScript API and Documentation section - SlideScript is a micro stripting language with the intent to give the world an effective shell like experience with the ability to use a sloppy syntax! SlideScript can do simple every day shell tasks like manipulating and working with files, and directories, piping, variable support, and backquoting, with a bit of spice like: built-in md5, and encoder / decoder, webserver, networking functions, tar and compression functions, PLUS MORE!" />
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table><tr><td>
<div class="header">
<img src="../sslogo.png" class="logoimg" title="SlideScript logo" alt="SlideScript" />
</div>
</td></tr><tr><td>
<div class="menu"><!--
--><a href="../index.html">Home</a><!--
--><a href="index.html">Documentation</a><!--
--><a href="https://notabug.org/Pentium44/slidescript">Git</a><!--
--></div>
</td></tr></table>
<div class="container">
<h2>Getting SlideScript</h2>
<p>
Starting off with SlideScript, you'll first need to obtain the source and build it.
We're going to assume you're using a *nix based system today, so the easiest way to
get the source is with a tool a developer should be familiar with: git.<br /><br />
<b>Installing system-wide:</b>
<pre><code>
# git clone https://notabug.org/Pentium44/slidescript
# cd slidescript/
# make & make install
# slidescript
ss:prompt:
</code></pre>
<b>Running after build:</b>
<pre><code>
# git clone https://notabug.org/Pentium44/slidescript
# cd slidescript/
# make
# ./slidescript
ss:prompt:
</code></pre>
From this step, you should easily have built SlideScript, and
would be sitting at the fancy incorporation of an interactive shell.
Want to use it at as a script? Just make a file "script.ss", and
add a shebang after system wide install:<br />
<code>#!/usr/bin/slidescript</code>
<br /> Of course, make sure your script is executable!
</p>
<h2>Variables &amp; strings</h2>
<p>
SlideScript will parse an equal character into a variable using the
contents on each side of such equal character. No quotes are needed
after an equal character and can be ended via new-line. You can print
variables and/or strings to stdout in SlideScript using the "print" function.
Examples (interactive and scripted):
<pre><code>
ss:prompt: buffer=This will be the contents of variable "buffer"
ss: var 'buffer' -> This is the contents of variable "buffer"
ss:prompt: print "%buffer%"
This is the contents of variable "buffer"
ss:prompt:
OR
#!/usr/bin/slidescript
# This is a comment, script away
buffer=This will be the contents of variable "buffer"
print "%buffer%"
# Unset function on variables similar to perl
unset "buffer" # Dumps buffer from memory!
</code></pre>
From here, we are going to be refering to all examples as scripts. Yes,
SlideScript does have interactive mode for being a convenient all-in-one
shell, but lets focus on the scripting side of things; shall we?
</p>
<h2>Piping, math &amp; backquoting</h2>
<p>
Piping is very similar to piping within a *nix shell. In SlideScript,
the piping character remains "vertical bar" or "|". The return value
of the function processed on the left side of the piping character will
be pushed into a variable known as "PIPE". Hmm, wonder why? :P
You can use piping in recursion in SlideScript. <br />
Backquotes or "`" are used within SlideScript, mainly in variables,
for processing functions within the language, and saving the returned value
as a string. For example: whatsthetime=`time` would be saved as:
ss: var 'whatsthetime' -> Wed Jun 9 17:56:23 2021<br />
Here are some examples:
<pre><code>
#!/usr/bin/slidescript
# First, lets show how a pipe works:
print "hello" | print "%PIPE% world" # Returns: hello world
# Now for stacked piping, lets use a variable with the current time, and
# Play with it!
whatsthetime=`time` # return: ss: var 'whatsthetime' -> Wed Jun 9 17:56:23 2021
calc "56.5 * 6.25" | print "Solved: %PIPE%" | print "[%whatsthetime%] %PIPE%"
### Return value of the contraption: [Wed Jun 9 17:56:23 2021] Solved: 353.125000
# This is more for, how math works in SlideScript #
# Example of using piping to do mathimatical equations with parathesis!
calc "33.3 / 2" | calc "%PIPE% * 26" | calc "%PIPE% + 2" # Return: 434.899994
</code></pre>
</p>
<h3>IRC server</h3>
<p>
Still need help? Want to report a bug? Join us!<br /><br />
IP/Port: cddo.cc/1337<br />
Main hang channel: <b>#theroot</b><br />
FreeBox channel: <b>#freebox</b><br />
FreonLinux channel: <b>#freonlinux</b>
</p>
</div>
<div class="footer">
&copy; Chris Dorman, 2021 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode">CC BY-NC-SA 4.0</a> - Software GPLv2 licensed<br />
<p>
Powered by:<br />
<a href="https://freedns.afraid.org/">
<img style="width:100px;" src="https://freedns.afraid.org/images/freedns_crop.png" />
</a>
<a href="https://letsencrypt.org/">
<img style="width: 100px;" src="https://letsencrypt.org/images/le-logo-wide.png" />
</a>
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:80px" src="http://jigsaw.w3.org/css-validator/images/vcss-blue" alt="Valid CSS!" />
</a>
</p>
</div>
</body>
</html>