美文网首页码农
SmallBASIC中文手册(刚翻译个开头)

SmallBASIC中文手册(刚翻译个开头)

作者: FSS_Sosei | 来源:发表于2019-09-26 08:58 被阅读0次

    官网:

    SmallBASIC | one more basic

    有木有同好可以继续翻译

      _____                _ _ ____          _____ _____ _____

      / ____|              | | |  _ \  /\    / ____|_  _/ ____|

    | (___  _ __ ___  __ _| | | |_) | /  \  | (___  | || |

      \___ \| '_ ` _ \ / _` | | |  _ < / /\ \  \___ \  | || |

      ____) | | | | | | (_| | | | |_) / ____ \ ____) |_| || |____

    |_____/|_| |_| |_|\__,_|_|_|____/_/    \_\_____/|_____\_____|

    1. (Console) AT

    AT x, y

    将控制台光标移动到指定位置。x、y的单位是像素。

    2. (Console) BEEP

    BEEP

    产生嘟一声。

    3. (Console) CLS

    CLS

    清除屏幕。

    4. (Console) FORM

    FORM(map)

    从映射变量创建表单对象。这提供了对以下子命令的访问:doEvents、close、refresh。

    表单映射可能包含以下属性:value、inputs、focus。

    输入是一个映射数组,每个映射可以包含以下属性: x、y、width、height、value、label、name、type、backgroundColor、color、visible、isExit、selectedIndex、length、noFocus、onclick

    type属性可以是以下属性之一:

    button

    label

    link

    tab

    listbox

    choice

    text

    image

    As far as I know FORM has replaced DOFORM. This example, since it is longer,  will be in the Code Demo section of the Code Library as well.

    Here is Chris code example of FORM's usage. As you can see, it requires knowledge of buttons and their properties. Also be forewarned this code will create the file: f.frm. I may have modified a few items playing with the code since Chris had posted it.

    ----[ FORM example. cut here ]--->

    f.handleKeys = 0

    ' create some buttons

    button1.y = 120

    button1.label = "Button1"

    button1.value = "valudofButton1"

    button1.backgroundcolor = rgb(255,0,0)

    button1.onclick = HelloWorld 'this prints on load

    button2.x = -1

    button2.y = 120

    button2.label = "Button2"

    button2.value = "valueofButton2"

    button3.type = "image"

    button3.value = "cats"

    button3.x = -1

    button3.y = 120

    button3.background = 223344

    b4.type = "choice"

    b4.value = "cats|dogs|Fish|cats|dogs|Fish|cats|dogs|Fish|cats|dogs|Fish"

    b4.selectedIndex = 2

    b4.x = -1

    b4.y = 120

    b5.type = "list"

    b5.value = "cats|dogs|Fish|cats|dogs|Fish|cats|dogs|Fish|cats|dogs|Fish|end|lol"

    b5.x = -1

    b5.y = 120

    b5.height = 120

    b6.type = "text"

    b6.value = "cats"

    b6.length=30

    b6.x = -1

    b6.y = 120

    b6.width = 50

    b6.noFocus = 0

    ' add buttons to the form

    f.inputs << button1

    f.inputs << button2

    f.inputs << button3

    f.inputs << b4

    f.inputs << b5

    f.inputs << b6

    f.backgroundcolor = "green"

    ' at this stage 'f' is just a plain user defined structure (map)

    ' after calling FORM, 'f' becomes a system form object with three special functions

    ' doEvents, close and refresh (see sokoban.bas for refresh)

    f = form(f)

    ' the string version of the form is JSON  (see https://en.wikipedia.org/wiki/JSON)

    TSAVE "f.frm", f

    while 1

      ' pump the system event queue

      f.doEvents()

      ' process the event

      in$ = inkey

      at 0,0

      if len(in$)>1 then

        flag= asc(left(in$,1))

        keychar =right(in$,1)

      n= asc(keychar)

        if (flag == 1)

          ? "Ctrl    : ";keychar ; "  "

        else if (flag == 2)

          ? "Alt    : "; keychar

        else if (flag == 3)

          ? "Ctrl+Alt: "; keychar ; "  "

        else

          ? "Arrow: "; n ; "  "

        end if

      else

        vkey = asc(in$)

        if (vkey == 8) then

          ? "backspace!"

        else if (vkey == 127) then

          ? "delete !"

        else

          ? " key=          "; in$; " "; vkey

        endif

    endif

    if b6.value <> "cats" then ? b6.value

      if (len(f.value) > 0) then

        print f.value; "                  "

      end if

    wend

    f.close()

    func HelloWorld

    ? "hello world"

    end

    <---[ cut here ]----

    5. (Console) INPUT

    INPUT [prompt,|;] var[, var [, ...]]

    读取“键盘”文本并将其存储在变量中。

    prompt后用“;”会自动在prompt字符串后添加一个“?”,而用“,”就不会。

    如果没有prompt,只有“;”,那么输入完成后光标还是定位在输入行,而不会正常换行

    6. (Console) LINEINPUT

    LINEINPUT [#fileN] var

    从文件号绑定的文件或从控制台读取整行文本。

    7. (Console) LINPUT

    LINPUT [#fileN] var

    从文件号绑定的文件或从控制台读取整行文本。

    8. (Console) LOCATE

    LOCATE y, x

    将控制台光标移动到指定位置。x、y的单位是文本字符行列位置。

    9. (Console) LOGPRINT

    LOGPRINT ...

    输出到应用程序日志文件。语法与PRINT命令相同。

    10. (Console) NOSOUND

    NOSOUND

    停止背景声音并清除声音队列。

    11. (Console) PEN

    PEN ON|OFF

    本程序内笔与鼠标功能的启用/禁用。

    12. (Console) PLAY

    PLAY string

    播放音符字串。

    A-G[-|+|#][nnn][.]

    A-G是7个音的音符

    “+”或“#”是升半音

    “-”是降半音

    nnn是数字,数字1就是一拍,64就是六十四分之一拍

    “.”是音符拍数延长0.5倍

    P[1..64]

    P是休止符,后面的数字1就是一拍,64就是六十四分之一拍

    Nnn是用“nn”1-84数字编号表示从低音到高音的音符,N0表示休止符

    “<”是表示降八度,这个符号之后会降八度来播放后面的音符;“>”是表示升八度,这个符号之后会升八度来播放后面的音符

    Tnnn是用数字32..255表示拍子为每分钟几拍。32就是以每分钟32拍的慢节奏播放之后的音符

    Lnn是用数字1..64表示之后的音符以1/nn拍播放

    ML是表示这个符号之后是以连音占空比(1)播放后面的音符;MN是表示这个符号之后是以普通占空比(3/4)播放后面的音符;MS是表示这个符号之后是以断音占空比(1/2)播放后面的音符

    Vnnn

    这是音量,这个符号之后的音符是以数字0..100指定的音量播放

    MF是表示这个符号之后的音符以前台播放方式放完才进行下一条语句;MB是表示这个符号之后的音符以后台方式播放,边播放边继续后面的语句。注意:后台播放时,当后面的语句都运行完毕到了程序结束,即使音符序列还没播放完程序也会结束而终止播放

    Q是表示清除Q之前还在后台播放的音符序列。当Q之前不是后台播放状态或后台播放的序列已经都放完了,那么遇到Q则没有任何作用

    13. (Console) PRINT

    PRINT [USING [format];] [expr|str [,|; [expr|str]] ...

    显示文本或表达式的值。

    *PRINT SEPARATORS*

    | TAB(n)| Moves cursor position to the nth column.|

    | SPC(n)| Prints a number of spaces specified by n.|

    | ;| Carriage return/line feed suppressed after printing.|

    | ,| Carriage return/line feed suppressed after printing.|

    *PRINT USING*

    Print USING uses the FORMAT() function to display numbers and strings. Unlike FORMAT it can also include literals.

    * [_] - Print next character as a literal. The combination _#, for example, allows you to include a number sign as a literal in your numeric format.

    * [other] Characters other than the foregoing may be included as literals in the format string.

    p.. When a PRINT USING command is executed the format will remains on the memory until a new format is passed. Calling a PRINT USING without a new format specified the PRINT will use the format of previous call.

    PRINT USING "##: #,###,##0.00";

    FOR i=0 TO 20

        PRINT USING; i+1, A(i)

    NEXT

    ....

    PRINT USING "Total ###,##0 of \\ \\"; number, "bytes"

    The symbol ? can be used instead of keyword PRINT You can use 'USG' instead of 'USING'.

    quote: <strong>It's all in the punctuation at the end of a print statement</strong>

    ----[ PRINT example. cut here ]--->

    REM 3 ways to print hello five time.bas 2016-03-05 SmallBASIC 0.12.2 [B+=MGA]

    'It's all in the punctuation at the end of a print statement

    '1) no punctiation  = whole print lines CR=carriage return and LF=line feed, ready to go on next line

    for i=1 to 5

      print "hello"

    next

    ?:? '2 blank lines

    '2) a comma which tabs to next avaiable tab column and will stay on same line until run out of coloumns

    for i=1 to 5

      print "hello",

    next

    ? "& this will finish the hello, line."

    ?:? 'the first ?=print will finish the print line, the 2 two are blank lines

    '3) a semicolon (and space after hello)

    for i=1 to 5

      print "hello";" ";  'or just print "hello ";

    next

    ? "... this line needs to be finsihed."

    pause

    <---[ cut here ]----

    To gain even more control of where your next PRINT statement will end up on screen checkout the older LOCATE keyword and the more modern method of using AT.

    ----[ PRINT example. cut here ]--->

    ' PRINT can also print to an open file or device (not only to console).

    ' Note: new-line (or line-break) character(s) is different on each system:

    '      Windows and DOS uses a pair of CR and LF characters to terminate lines.

    '      UNIX, Linux, FreeBSD and OS X uses a single LF character only.

    '      Classic Mac operating system uses a single CR character only.

    '      * CR is CHR(13); LF is CHR(10).

    ' Print lines to demo file:

    Open "PRINT.TMP" For Output As #1

    Print #1, "hello_1" ' print [hello new-line]

    Print #1, "Hello_2", "Hello_3"  ' print [hello tab hello new-line]

    Print #1, "Hello_4"; "Hello_5"; ' print [hello hello]

    Print #1, ' print [new-line]

    Print #1, ' print [new-line]

    Print #1, ; ' print [].

    Print #1, Using "000 &"; 55, "is my mailbox" ' print [055... new-line]

    ? #1, "Hello_?" ' print [Hello_? new-line]

    Close #1

    ' Load lines from demo file and print them to console:

    Open "PRINT.TMP" For Input As #1

    Color 0, 7

    While Not Eof(1) Do

      Lineinput #1, s

      Print s

    Wend

    Close #1

    Pause

    <---[ cut here ]----

    14. (Console) SOUND

    SOUND freq, dur_ms [, vol] [BG]

    发出指定频率的声音。

    * freq 是频率

    * dur_ms 持续时间(毫秒)

    * vol 音量(0..100)

    * BG 设在后台播放

    相关文章

      网友评论

        本文标题:SmallBASIC中文手册(刚翻译个开头)

        本文链接:https://www.haomeiwen.com/subject/kndguctx.html