Friday, 20 April 2012

System object exposed

System object is the core of Rebol configuration, but it's difficult to understand so this post will clarify a little about it.
Since it's an object, you can't call its element with the numbers (system/1),  but you need to know its composition:

>> system/version
== 2.7.8.3.1


How it is composed (click on a name to jump to the relative section):
Lets analyze one by one:


Version

It contains the number version, the first 3 digits are core version, the fourth the platform, the fifth is processor type.
Examples:
  • 2.7.8.3.1    version for Windows
  • 2.7.8.2.4    version for Apple with PPC cpu
  • 2.7.8.2.5    version for Apple with Intel cpu
  • 2.7.8.4.2    version for Linux
  • 2.7.8.7.2    version for FreeBSD
  • 2.7.8.9.4    version fot OpenBSD


Build


The date of building the current Rebol version:

>> system/build
== 1-Jan-2011/16:39:07-8:00



Product


It explains what Rebol product are you using:

>> system/product
== View


Core


It explains what core Rebol version are you using:

>> system/core
== 2.7.8


Components


This is a block made of 60 items, they are just 30 object with name before and none after them in the block:

>> for i 1 60 3 [ print system/components/:i ]
mezz
registry
getprefs
Install
protocols
ODBC
Library
shell
graphics
draw
view
viewtop
sound
crypt
bignum
dhdsa
rsa
sysport
crypt2
ssl

Each object is made of all descriptions of the component (title, owner, version, etc.):

>> print system/components/mezz
make object! [
Title: "REBOL Mezzanine Extensions"
Date: 1-Aug-2004/21:34:12
Name: 'mezz
Version: 1.2.0
File: none
Home: none
Author: none
Owner: none
Rights: none
Needs: none
Tabs: none
Usage: none
Purpose: none
Comment: none
History: none
Language: none
Type: none
Content: none
]


Words


It's an object, it contains all Rebol reserved words, if type is unset!, it means that is a dialect world and it works just in a Rebol dialect.
At the moment it contains 2642 reserved words. Some owrds can be a block or an object.


License


It's the Rebol license:
REBOL End User License Agreement

IMPORTANT. READ CAREFULLY.

This License Agreement (AGREEMENT) is a legal contract between
you and REBOL Technologies (REBOL) for the limited use of this
REBOL software product (SOFTWARE), which includes computer
software, and, as applicable, associated media, printed
materials, and electronic documentation.

REBOL grants you a non-exclusive license to use the SOFTWARE.
The SOFTWARE is licensed, not sold, to you. REBOL retains all
right, title, and interest in and to the SOFTWARE including,
without limitation, all intellectual property rights relating to
or embodied in the SOFTWARE.

The copyright, trademark, and other proprietary rights notices
contained in the SOFTWARE may not be removed, altered, or added
to in any way. You may not reverse engineer, decompile, or
disassemble the SOFTWARE.

You agree to use the SOFTWARE in compliance with all applicable
laws and regulations including all laws governing the export or
re-export of the SOFTWARE. You agree to indemnify REBOL from
and against your violation of any such laws or regulations.

You may redistribute the SOFTWARE provided that you include this
entire License AGREEMENT and all copyright and trademark
notices; and agree to indemnify, hold harmless, and defend
REBOL from and against any claims or lawsuits, including
attorneys' fees, that arise from use, reproduction, or
distribution of the SOFTWARE.

THE SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTY
OF ANY KIND, EXPRESS, IMPLIED OR STATUTORY INCLUDING WITHOUT
LIMITATION ANY IMPLIED WARRANTIES OF MERCHANTABILITY,
NONINFRINGEMENT OR FITNESS FOR PARTICULAR USE OR PURPOSE.

IN NO EVENT SHALL REBOL OR ITS SUPPLIERS OR RESELLERS BE LIABLE
TO YOU OR ANY OTHER PERSON FOR ANY INDIRECT, SPECIAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY KIND INCLUDING,
WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS OR DATA, ARISING
OUT OF THIS AGREEMENT OR USE OF THE SOFTWARE. IN NO EVENT WILL
REBOL BE LIABLE FOR (a) ANY DAMAGES IN EXCESS OF THE AMOUNT
REBOL RECEIVED FROM YOU FOR A LICENSE TO THE SOFTWARE, EVEN IF
REBOL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND
NOTWITHSTANDING THE FAILURE OF ESSENTIAL PURPOSE OF ANY REMEDY,
OR (b) FOR ANY CLAIM BY ANY THIRD PARTY.

This AGREEMENT shall be governed by the laws of the State of
California. If any provision of this AGREEMENT is held to be
unenforceable, such provision shall be reformed only to the
extent necessary to make it enforceable.

This AGREEMENT contains the entire agreement between the parties
with respect to the license of the SOFTWARE. This AGREEMENT
supersedes any prior license agreement of the SOFTWARE.

By installing or using the SOFTWARE, you are consenting to be
bound by and are becoming a party to this AGREEMENT. If you do
not agree to all of the terms of this AGREEMENT, do not use the
SOFTWARE.

REBOL can be contacted at WWW.REBOL.COM



Options


It contains Rebol options like path to executable:

[
home: %/c/programmi/rebol/view/
script: none
path: %/c/programmi/rebol/view/
boot: %/C/Programmi/rebol/view/rebol.exe
args: none
do-arg: none
link-url: none
server: none
quiet: true
trace: false
help: false
install: none
boot-flags: 16
boot-version: none
binary-base: 16
cgi: make object! [
server-software: none
server-name: none
gateway-interface: none
server-protocol: none
server-port: none
request-method: none
path-info: none
path-translated: none
script-name: none
query-string: none
remote-host: none
remote-addr: none
auth-type: none
remote-user: none
remote-ident: none
Content-Type: none
content-length: none
other-headers: []
]
browser-type: 0
]



User


It contains all user informations:

name: "MaxV"
email: maxint@tiscali.it
home: none
words: none


Script


It became the current script header, if you aren't using any script it's like this:

title: none
header: none
parent: none
path: %/c/programmi/rebol/view/
args: none
words: none


Console


It contains the console history, the symbol to use at prompt, the escape sequence, the busy symbols, the tab size and the function for automatic completion:

>> probe system/console
make object! [
history: ["probe system/console"]
keys: none
prompt: ">> "
result: "== "
escape: "(escape)"
busy: "|/-\"
tab-size: 4
break: true
lookup: func [
"Console filename completion lookup."
file /value
][
if #"/" <> last file [file: first split-path file]
attempt [read file]
]
]


So you can change the console behavior:

>> system/console/prompt: "Command> "
== "Command> "
Command> system/console/result: "Result-> "
Result-> "Result-> "
Command> print "Hello"
Hello
Command> 2 - 2
Result-> 0


Ports


It contains six ports:
  • input
  • output
  • echo
  • system
  • serial
  • wait-list
Input and output are used for CGI script, for example an HTML use a script:

<html>
<form action="testpost.r" method="POST">
<input maxlength="20" name="name" size="20" type="text" />
<input type="submit" value="OK" />
</form>
</html>


testpot.r is:
#!/path/to/rebol -c
    REBOL [Title: "Print POST Data"]
    ;- Always print this line first
    print ["Content-type: text/html" newline newline]
    post-data: copy system/ports/input
    print [<HTML><PRE> post-data </PRE></HTML>]
    quit


Network


It contains PC name and IP:

>> help system/network
SYSTEM/NETWORK is an object of value:
host string! "PC19"
host-address tuple! 192.1.1.1


Schemes


It contains some standard network schemes used:
  • default
  • finger
  • whois
  • daytime
  • smtp
  • esmtp
  • pop
  • imap
  • http
  • ftp
  • nntp
  • https
You can change  or create your connections. For example if you need to connect to an FTP site, always with the same user name and password, just edit the FTP scheme, and every time you use the FTP port, rebol will use your user name and password:

>> system/schemes/ftp/user: 741856@aruba.it
>> system/schemes/ftp/pass: "secretxxxyyyy"
>> foreach item ( read ftp://ftp.rebol2.it/main/) [ print item]
1-9stylesheet.css
16-11-07stylesheet.css
16-2stylesheet.css
30-1stylesheet.css
Policarpa.jpg
Technip3.zip
_index.html
c4i/
cgi-bin/
chat-test.html
english/
gpEasy/
gpEasy_en/
htaccess.txt
immagini/
index.html
indirizzo.gif
info.php
infophp.php
it/
italiano/
postinfo.html
prototype.js
recaptchalib.php
robots.txt
sessioni.php
sfondo.jpg
stile.css
stylesheet.css
temp/
uploads/



In order to obtain more information about a scheme, use help:


>> help system/schemes/http
SYSTEM/SCHEMES/HTTP is an object of value:
   scheme          word!     HTTP
   host            none!     none
   port-id         integer!  80
   user            none!     none
   pass            none!     none
   target          none!     none
   path            none!     none
   proxy           object!   [host port-id user pass type bypass]
   access          none!     none
   allow           none!     none
   buffer-size     none!     none
   limit           none!     none
   handler         object!   [port-flags open-check close-check write-check ini...
   status          none!     none
   size            none!     none
   date            none!     none
   url             none!     none
   sub-port        none!     none
   locals          none!     none
   state           none!     none
   timeout         none!     none
   local-ip        none!     none
   local-service   none!     none
   remote-service  none!     none
   last-remote-service none! none
   direction       none!     none
   key             none!     none
   strength        none!     none
   algorithm       none!     none
   block-chaining  none!     none
   init-vector     none!     none
   padding         none!     none
   async-modes     none!     none
   remote-ip       none!     none
   local-port      none!     none
   remote-port     none!     none
   backlog         none!     none
   device          none!     none
   speed           none!     none
   data-bits       none!     none
   parity          none!     none
   stop-bits       none!     none
   rts-cts         logic!    true
   user-data       none!     none
   awake           none!     none
   passive         none!     none
   cache-size      integer!  5
   user-agent      string!   "REBOL View 2.7.8.3.1"





Error


It contains all error messages, please read http://www.rebol.com/docs/core23/rebolcore-17.html. Errors are divided in:
  • throw     
  • note
  • syntax
  • script
  • math
  • access
  • command
  • resv700
  • user
  • internal
For example:

>> system/error/syntax/type
== "Syntax Error"
>> system/error/syntax/invalid
== ["Invalid" :arg1 "--" :arg2]



Standard


It contains all standard objects, so you can copy them to obtain a complete object. It contains:
  • script
  • port
  • port-flags
  • email
  • face
  • sound
  • error
  • port-state
  • compress
  • checksum
  • net-interface
  • license
  • shell
  • crypt
  • crypt-dh
  • crypt-dsa
  • crypt-dsa-sig
  • crypt-rsa
You can use them this way:

>> temp: make system/standard/email []
>> ? temp
TEMP is an object of value:
To none! none
CC none! none
BCC none! none
From none! none
Reply-To none! none
Date none! none
Subject none! none
Return-Path none! none
Organization none! none
Message-Id none! none
Comment none! none
X-REBOL string! "View 2.7.8.3.1 http://WWW.REBOL.COM"
MIME-Version none! none
Content-Type none! none
Content none! none


View


It contains all words and object (also images) of the View or VID systems. It's huge!


Stats


Is the memory used in bit:

>> system/stats
== 545527840

Locale

Locale contains the names of day and months:

>> probe system/locale
make object! [
months: [
"January" "February" "March" "April" "May" "June"
"July" "August" "September" "October" "November" "December"
]
days: [
"Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday"
]
]


User-license


Here there are the data to unlock all the advanced feature of Rebol/Command:
  • MySQL and Oracle database interfaces
  • ODBC (SQLServer, Access, Excel) database interface
  • Access to external libraries (DLLs)
  • SSL secure sockets (HTTPS client)
  • Built-in RSA, AES, Blowfish, DSA, DH encryption
  • Shell commands, launch external apps
  • Windows Registry access functions
  • Fast CGI server interface (quicker than standard CGI)


>> help system/user-license
SYSTEM/USER-LICENSE is an object of value:
name none! none
email none! none
id none! none
message none! none

No comments:

Post a Comment