📄 yabasic.1
字号:
The at-clause takes two numeric arguments (e.g. at(2,3)) and can be inserted after the print-keyword. at() can be used only if clear screen has been executed at least once within the program (otherwise you will get an error). The two numeric arguments of the at-function may range from 0 to the width of your terminal minus 1, and from 0 to the height of your terminal minus 1; if any argument exceeds these values, it will be truncated accordingly. However, yabasic has no influence on the size of your terminal (80x25 is a common, but not mandatory), the size of your terminal and the maximum values acceptable within the at-clause may vary. To get the size of your terminal you may use the peek-function: peek("screenwidth") returns the width of your terminal and peek("screenheight") its height.Exampleclear screenmaxx=peek("screenwidth")-1:maxy=peek("screenheight")-1for x=0 to maxx print at(x,maxy*(0.5+sin(2*pi*x/maxx)/2)) "*"next x This example plots a full period of the sine-function across the screen.See also print, clear screen, color _________________________________________________________________Name atan() - returns the arctangent of its numeric argumentSynopsisangle=atan(a,b)angle=atan(a)Description atan is the arctangent-function, i.e. the inverse of the tan-function. Or, more elaborate: It Returns the angle (in radian, not degree !), which, fed to the tan-function will produce the argument passed to the atan-function. The atan-function has a second form, which accepts two arguments: atan(a,b) which is (mostly) equivalent to atan(a/b) except for the fact, that the two-argument-form returns an angle in the range -pi to pi, whereas the one-argument-form returns an angle in the range -pi/2 to pi/2. To understand this you have to be good at math.Exampleprint atan(1),atan(tan(pi)),atan(-0,-1),atan(-0,1) This will print 0.463648 2.06823e-13 -3.14159 3.14159 which is pi/4, almost 0, -pi and pi respectively.See also tan, sinB backcolor - change color for background of graphic window backcolour - see backcolor beep - ring the bell within your computer; a synonym for bell bell - ring the bell within your computer (just as beep) bin$() - converts a number into a sequence of binary digits bind() - Binds a yabasic-program and the yabasic-interpreter together into a standalone program. box - draw a rectangle. A synonym for rectangle break - breaks out of a switch statement or a loopName color - change color for background of graphic windowSynopsisbackcolour red,green,bluebackcolour "red,green,blue"Description Change the color, that becomes visible, if any portion of the window is erased, e.g. after clear window or clear line. Note however, that parts of the window, that display the old background color will not change. As with the color-command, the new background color can either be specified as a triple of three numbers or as a single string, that contains those three numbers sperated by commas.Exampleopen window 255,255for x=10 to 235 step 10:for y=10 to 235 step 10 backcolour x,y,0 clear window sleep 1next y:next x This changes the background colour of the graphic window repeatedly and clears it every time, so that it is filled with the new background colour.See also open window, color, line, rectangle, triangle, circle _________________________________________________________________Name backcolour - see backcolorSynopsisbackcolour red,green,bluebackcolour "red,green,blue"See also color _________________________________________________________________Name beep - ring the bell within your computer; a synonym for bellSynopsisbeepDescription The bell-command rings the bell within your computer once. This command is not a sound-interface, so you can neither vary the length or the height of the sound (technically, it just prints \\a). bell is exactly the same as beep.Examplebeep:print "This is a problem ..." See also beep _________________________________________________________________Name bell - ring the bell within your computer (just as beep)SynopsisbellDescription The beep-command rings the bell within your computer once. beep is a synonym for bell.Exampleprint "This is a problem ...":beep See also bell _________________________________________________________________Name bin$() - converts a number into a sequence of binary digitsSynopsishexadecimal$=bin$(decimal)Description The bin$-function takes a single numeric argument an converts it into a string of binary digits (i.e. zeroes and ones). If you pass a negative number to bin$, the resulting string will be preceded by a '-'. If you want to convert the other way around (i.e. from binary to decimal) you may use the dec-function.Examplefor a=1 to 100 print bin$(a)next a This example prints the binary representation of all digits between 1 and 100.See also hex$, dec _________________________________________________________________Name bind() - Binds a yabasic-program and the yabasic-interpreter together into a standalone program.Synopsisbind("foo.exe")Description The bind-command combines your own yabasic-program (plus all the libraries it does import) and the interpreter by copying them into a new file, whose name is passed as an argument. This new program may then be executed on any computer, even if it does not have yabasic installed. Please see the section about creating a standalone-program for details.Exampleif (!peek("isbound")) then bind "foo" print "Successfully created the standalone executable 'foo' !" exitendifprint "Hello World !" This example creates a standalone program foo from itself.See also The section about creating a standalone-program, the peek-function and the commandline options for Unix and Windows. _________________________________________________________________Name box - draw a rectangle. A synonym for rectangleSynopsisSee the rectangle-command.Description The box-command does exactly the same as the rectangle-command; it is just a synonym. Therefore you should refer to the entry for the rectangle-command for further information. _________________________________________________________________Name break - breaks out of a switch statement or a loopSynopsisbreakDescription break transfers control immediately outside the enclosing loop or switch statement. This is the preferred way of leaving a such a statement (rather than goto, which is still possible in most cases).Examplefor a=1 to 10 break print "Hi"next awhile(1) break print "Hi"wendrepeat break print "Hi"until(0)switch 1case 1:breakcase 2:case 3:print "Hi"end switch This example prints nothing at all, because each of the loops (and the switch-statement) does an immediate break (before it could print any "Hi").See also for, while, repeat and switch.C case - mark the different cases within a switch-statement chr$() - accepts a number and returns the character at this position within the ascii charset circle - draws a circle in the graphic-window clear - Erase circles, rectangles or triangles clear screen - erases the text window clear window - clear the graphic window and begin a new page, if printing is under way close - close a file, which has been opened before close curve - close a curve, that has been drawn by the line-command close printer - stops printing of graphics close window - close the graphics-window color - change color for any subsequent drawing-command colour - see color compile - compile a string with yabasic-code on the fly continue - start the next iteration of a for-, do-, repeat- or while-loop cos() - return the cosine of its single argumentName case - mark the different cases within a switch-statementSynopsisswitch a case 1 case 2 ...end switch...switch a$ case "a" case "b" ...end switchDescription Please see the switch-statement.Exampleinput aswitch(a) case 1:print "one":break case 2:print "two":break default:print "more"end switch Depending on your input (a number is expected) this code will print one or two or otherwise more.See also switch _________________________________________________________________Name chr$() - accepts a number and returns the character at this position within the ascii charsetSynopsischaracter$=chr$(ascii)Description The chr$-function is the opposite of the asc-function. It looks up and returns the character at the given position within the ascii-charset. It's typical use is to construct nonprintable characters which do not occur on your keyboard. Nevertheless you won't use chr$ as often as you might think, because the most important nonprintable characters can be constructed using escape-sequences using the \\-character (e.g. you might use \\n instead of chr$(10) wherever you want to use the newline-character).Exampleprint "a",chr$(10),"b" This will print the letters 'a' and 'b' in different lines because of the intervening newline-character, which is returned by chr$(10).See also asc _________________________________________________________________Name circle - draws a circle in the graphic-windowSynopsiscircle x,y,rclear circle x,y,rfill circle x,y,rclear fill circle x,y,rDescription The circle-command accepts three parameters: The x- and y-coordinates of the center and the radius of the circle. Some more observations related with the circle-command: * The graphic-window must have been opened already. * The circle may well extend over the boundaries of the window. * If you have issued open printer before, the circle will finally appear in the printed hard copy of the window. * fill circle will draw a filled (with black ink) circle. * clear circle will erase (or clear) the outline of the circle. * clear fill circle or fill clear circle will erase the full area of the circle.Exampleopen window 200,200for n=1 to 2000 x=ran(200) y=ran(200) fill circle x,y,10 clear fill circle x,y,8next n This code will open a window and draw 2000 overlapping circles within. Each circle is drawn in two steps: First it is filled with black ink (fill circle x,y,10), then most of this circle is erased again (clear fill circle x,y,8). As a result each circle is drawn with an opaque white interior and a 2-pixel outline (2-pixel, because the radii differ by two).See also open window, open printer, line, rectangle, triangle _________________________________________________________________Name clear - Erase circles, rectangles or trianglesSynopsisclear rectangle 10,10,90,90clear fill circle 50,50,20clear triangle 10,10,20,20,50,30Description May be used within the circle, rectangle or triangle command and causes these shapes to be erased (i.e. be drawn in the colour of the background). fill can be used in conjunction with and wherever the fill-clause may appear. Used alone, clear will erase the outline (not the interior) of the shape (circle, rectangle or triangle); together with fill the whole shape (including its interior) is erased.Exampleopen window 200,200fill circle 100,100,50clear fill rectangle 10,10,90,90 This opens a window and draws a pacman-like figure.See also
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -