• rebol高速入门


    看了Java夜未眠之后,我也有点想学习其它语言了,希望能够完毕Python在写GUI程序和Web的程序的缺陷,写GUI程序比較看好VB,写Web程序看好PHP,不过首先想玩玩rebol。

    翻译的Rebol Quick Start http://www.rebol.com/docs/quick-start.html


    1.1 安装rebol
        安装rebol,too easy了,到http://www.rebol.com/download.html下载相应的rebol就能够了,我下载的是Rebol/View版的,说真的,挺象试试Pro版的,不过不是免费的啊。
        下载完之后你就能够使用rebol了,直接双节就能够(Windows平台),但你不妨建个单独的目录吧,由于兴许的操作中rebol会自己主动创建一些文件,不事先规划下挺烦人的啊。

    1.2 样例
    1. REBOL [
    2.     Title: "Digital Clock"
    3.     Version: 1.3.3
    4.     Author: "Carl Sassenrath"
    5.     Purpose: {A simple digital clock.}
    6. ]
    7. f: layout [
    8.     origin 0
    9.     b: banner 140x32 rate 1 
    10.         effect [gradient 0x1 0.0.150 0.0.50]
    11.         feel [engage: func [f a e]
    12.                         [set-face b now/time]]
    13. ]
    14. view f

       在命令行里输入rebview sample.r,就能够打开一个时钟。
       如今来看上面的代码,非常容易能够看到上面的东东分3个部分,REBOL部分、f部分和view f部分。
    1.2.1 header  
       在rebol中REBOL部分被称作头部header,这部分是强制的,就是说没有这部分,程序就无法执行;这个规定非常奇怪,假设不过为了版权问题的话,实在是没什么道理的。
       header部分一般能够包括script name,author,date,version,file name,addtional information而言,头部写法为:
       REBOL [block]
       一个典型的header看起来可能像这个样子:
    1. REBOL [
    2.     Title:   "Full REBOL Header Example"
    3.     Date:    8-Sep-1999
    4.     Name:    'Full-Header  ; For window title bar
    5.     Version: 1.1.1
    6.     File:    %headfull.r
    7.     Home:    http://www.rebol.com/rebex/
    8.     Author:  "Carl Sassenrath"
    9.     Owner:   "REBOL Headquarters"
    10.     Rights:  "Copyright (C) Carl Sassenrath 1999"
    11.     Needs:   [2.0 ODBC]
    12.     Tabs:    4
    13.     Purpose: {
    14.         The purpose or general reason for the program
    15.         should go here.
    16.     }
    17.     Note: {
    18.         An important comment or notes about the program
    19.         can go here.
    20.     }
    21.     History: [
    22.         0.1.0 [5-Sep-1999 "Created this example" "Carl"]
    23.         0.1.1 [8-Sep-1999 {Moved the header up, changed
    24.             comment on extending the header, added
    25.             advanced user comment.} "Carl"]
    26.     ]
    27.     Language: 'English
    28. ]
    1.2.2 body部分
       body部分在上面的样例中主要唯独一个变量f
       f: layout[],这个语句创建了一个窗体
       终于view f的时候打开该窗体
       甚至你能够在console里输入
       f: layout[]
       view f
       相同能够看到这个窗体

    1.3 IDE
       写IDE似乎蛮吓人的啊,情况没那么吓人,作者给我们推荐了一个内置了语法高亮的编辑器Crimson Editor,下载地址是http://www.crimsoneditor.com/,经过简单的配置就能够通过Ctrl+E执行rebol程序了。

    1.3.1 色彩配置
       Tools->Preference->Colors
       background:黑色
       activeline:黑色
       normal text:白色
       constant:绿色
       string:绿色
       commet:白色
       variable:蓝色
       Keywords:红色

    1.3.2 编辑器配置
       Tools->Preference->User Tools
       Menu Text:Rebol
       Command:F:/rebview/rebview.exe(依照你自己的相应的调整)
       Argument:-s $(FilePath)
       Init Dir:$(FileDir)
       Hot Key:Ctrol+E
       经过測试,OK了的。

    2 编程入门

    2.1 Hello World

    1. REBOL []
    2. alert "Hello World!"
      样例非常easy,弹出一个对话框,内容当然就是Hello World了。
      注意:在Rebol中,断行是不重要的,但空格是非常重要的;这大约是Rebol的设计理想之中的一个,Using Rebol should be the same as using English.英语似乎每一个单词周围都是有空格的。

    2.2 第二个程序
    1. REBOL []
    2. birthday: 15-Dec-1984
    3. alert reform ["You are " now - birthday "days old"]
    的确挺象英语的,嘿嘿。

    2.3 第三个程序
    1. REBOL []
    2. view layout [
    3.     backcolor gold
    4.     h2 "Web Bookmarks"
    5.     style btn btn 130
    6.     btn "REBOL.com" [browse http://www.rebol.com]
    7.     btn "REBOL.net" [browse http://www.rebol.net]
    8.     btn "REBOL.org" [browse http://www.rebol.org]
    9.     btn "google" [browse http://www.google.cn]
    10. ]
       非常有趣,有点CSS style,挺不错的,非常有点吸引人。
       这个程序的layout里面每行都有4个空格,还好这不是强制的,不过一种风格。

     
  • 相关阅读:
    asp.net core 3.1 入口:Program.cs中的Main函数
    vue手机发送验证码倒计时
    阿里云短信服务-短信发送验证码
    前端思维图
    正向代理和反向代理
    lombok+Logback统一异常和日志处理
    java统一结果返回(链式编程结果)
    SpringBoot简介和特点
    web如何测试?
    CSS字体样式属性
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/3903286.html
Copyright © 2020-2023  润新知