SlideScript

If you're following through the API documentation, chapter by chapter, then you have a good idea of the foundation of the language in terms of it's structure. Now for some features of SlideScript. File manipulation is definitely something that can be tackled without a doubt. A selection of functions within SlideScript that are file related are: isfile, isdir, showdir (ls), showpath (pwd), move (mv), delete, chdir (cd), read, write, and cat.

To be honest, how could SlideScript be shell like without having the functionality of all the system utilities. Here's the kicker, everything is built-in to the core of SlideScript, making it extremely versatile and super simple! No dependency on other software!


#!/usr/bin/slidescript
# File manipulation examples

# showdir: list directories/files in current directory.
# argument count: 0
# returns: file list.
showdir
ls # alias

# showpath: show current working directory location (alias pwd).
# argument count: 0
# returns: working directory path
showpath
pwd # alias

# chdir: Change directory 
# argument count: 1, "path" ex: "docs/"; "/home/user"
# returns: No return
chdir "docs/"
showpath # Show return of change

# backdir: Back a directory / to parent directory (same as chdir "..")
# argument count: 0
# returns: No return
backdir

# isdir / isfile: Return true or false (0 or 1) on file / directory find.
# argument count: 1, "file/path" ex: "docs/README.txt"
# returns: true / false
isfile "docs/README.txt" # returns: true
isdir "docs/" # returns: true
isfile "docs/" # returns: false

# move: move file / rename file based on arguments.
# argument count: 2, "original" "new file name/location", ex: "docs/" "documents/"
# returns: no return
move "docs" "documents" # renamed docs -> documents

# delete: delete file (non-recursive)
# argument count: 1, "filename", ex: "docs/README.txt"
# return: no return
delete "docs/README.txt" # deletes README.txt inside docs/

# read: read contents of file given to function
# argument count: 1, "file", ex: "docs/README.txt"
# return: contents of file
read "docs/README.txt" # Returns contents of "README.txt"

# write: write contents to file.
# argument count: 2, "filename" "contents", ex: "test.txt" "Hello world!"
# return: no return
write "test.txt" "Hello world!"

# cat: catenate file with given contents
# argument count: 2, "file" "contents", ex: "test.txt" "I'm back!"
# return: no return
cat "test.txt" "I'm back!" # catenates "I'm back!" to the end of the original test.txt "Hello world!"
# Ending file contents of "test.txt":
#   Hello world!
#   I'm back!

IRC server

Still need help? Want to report a bug? Join us!

IP/Port: cddo.cc/1337
Main hang channel: #theroot
FreeBox channel: #freebox
FreonLinux channel: #freonlinux