📄 yabasic.1
字号:
execute() execute a user defined subroutine, which must return a number exit terminate your program pause pause, sleep, wait for the specified number of seconds peek retrieve various internal informations peek$ retrieve various internal string-informations poke change selected internals of yabasic rem start a comment sleep pause, sleep, wait for the specified number of seconds system$() hand a statement over to your operating system and return its output system() hand a statement over to your operating system and return its exitcode time$ return a string containing the current time to this keyword appears as part of other statements wait pause, sleep, wait for the specified number of seconds // starts a comment : separate commands from each otherGraphics and printing backcolor specify the colour for subsequent drawing of the background box draw a rectangle. A synonym for rectangle circle draws a circle in the graphic-window clear Erase circles, rectangles or triangless clear window clear the graphic window and begin a new page, if printing is under way close curve close a curve, that has been drawn by the line-command close window close the graphics-window colour specify the colour for subsequent drawing dot draw a dot in the graphic-window fill draw a filled circles, rectangles or triangles getbit$() return a string representing the bit pattern of a rectangle within the graphic window line draw a line mouseb extract the state of the mousebuttons from a string returned by inkey$ mousemod return the state of the modifier keys during a mouseclick mousex return the x-position of a mouseclick mousey return the y-position of a mouseclick new curve start a new curve, that will be drawn with the line-command open window open a graphic window putbit draw a rectangle of pixels into the graphic window rectangle draw a rectangle triangle draw a triangle text write text into your graphic-window window origin move the origin of a windowChapter 6. All commands and functions of yabasic grouped alphabetically A B C D E F G H I L M N O P R S T U V W X Special characters Reserved WordsA abs() - returns the absolute value of its numeric argument acos() - returns the arcus cosine of its numeric argument and - logical and, used in conditions and() - the bitwise arithmetic and arraydim() - returns the dimension of the array, which is passed as an array reference arraysize() - returns the size of a dimension of an array asc() - accepts a string and returns the position of its first character within the ascii charset asin() - returns the arcus sine of its numeric argument at() - can be used in the print-command to place the output at a specified position atan() - returns the arctangent of its numeric argumentName abs() - returns the absolute value of its numeric argumentSynopsisy=abs(x)Description If the argument of the abs-function is positive (e.g. 2) it is returned unchanged, if the argument is negative (e.g. -1) it is returned as a positive value (e.g. 1).Exampleprint abs(-2),abs(2) This example will print 2 2See also sig _________________________________________________________________Name acos() - returns the arcus cosine of its numeric argumentSynopsisx=acos(angle)Description acos is the arcus cosine-function, i.e. the inverse of the cos-function. Or, more elaborate: It Returns the angle (in radian, not degree !), which, fed to the cosine-function will produce the argument passed to the acos-function.Exampleprint acos(0.5),acos(cos(pi)) This example will print 1.0472 3.14159 which are pi/3 and pi respectively.See also cos, asin _________________________________________________________________Name and - logical and, used in conditionsSynopsisif (a and b) ...while (a and b) ...Description Used in conditions (e.g within if, while or until) to join two expressions. Returns true, if and only if its left and right argument are both true and false otherwise. Note, that logical shortcuts may take place.Exampleinput "Please enter a number" aif (a>=1 and a<=9) print "your input is between 1 and 9" See also or,not _________________________________________________________________Name and() - the bitwise arithmetic andSynopsisx=and(a,b)Description Used to compute the bitwise and of both its argument. Both arguments are treated as binary numbers (i.e. a series of 0 and 1); a bit of the resulting value will then be 1, if both arguments have a 1 at this position in their binary representation. Note, that both arguments are silently converted to integer values and that negative numbers have their own binary representation and may lead to unexpected results when passed to and.Exampleprint and(6,3) This will print 2. This result is clear, if you note, that the binary representation of 6 and 3 are 110 and 011 respectively; this will yield 010 in binary representation or 2 as decimal.See also or, eor and not _________________________________________________________________Name arraydim() - returns the dimension of the array, which is passed as an array referenceSynopsisa=arraydim(b())Description If you apply the arraydim()-function on a one-dimensional array (i.e. a vector) it will return 1, on a two-dimensional array (i.e. a matrix) it will return 2, and so on. This is mostly used within subroutines, which expect an array among their parameters. Such subroutines tend to use the arraydim-function to check, if the array which has been passed, has the right dimension. E.g. a subroutine to multiply two matrices may want to check, if it really is invoked with two 2-dimensional arrays.Exampledim a(10,10),b(10)print arraydim(a()),arraydim(b()) This will print 2 1, which are the dimension of the arrays a() and b(). You may check out the function arraysize for a full-fledged example.See also arraysize and dim. _________________________________________________________________Name arraysize() - returns the size of a dimension of an arraySynopsisx=arraysize(a(),b)Description The arraysize-function computes the size of a specified dimension of a specified array. Here, size stands for the maximum number, that may be used as an index for this array. The first argument to this function must be an reference to an array, the second one specifies, which of the multiple dimensions of the array should be taken to calculate the size. An Example involving subroutines: Let's say, an array has been declared as dim a(10,20) (that is a two-dimensional array or a matrix). If this array is passed as an array reference to a subroutine, this sub will not know, what sort of array has been passed. With the arraydim-function the sub will be able to find the dimension of the array, with the arraysize-function it will be able to find out the size of this array in its two dimensions, which will be 10 and 20 respectively. Our sample array is two dimensional; if you envision it as a matrix this matrix has 10 lines and 20 columns (see the dim-statement above. To state it more formally: The first dimension (lines) has a size of 10, the second dimension (columns) has a size of 20; these numbers are those returned by arraysize(a(),1) and arraysize(a(),2) respectively. Refer to the example below for a typical usage.Exampleremrem This program adds two matrices elementwise.remdim a(10,20),b(10,20),c(10,20)rem initialization of the arrays a() and b() for y=1 to 10:for x=1 to 20 a(y,x)=int(ran(4)):b(y,x)=int(ran(4))next x:next ymatadd(a(),b(),c())print "Result:"for x=1 to 20 for y=10 to 1 step -1 print c(y,x)," "; next y printnext xsub matadd(m1(),m2(),r()) rem This sub will add the matrices m1() and m2() rem elementwise and store the result within r() rem This is not very useful but easy to implement. rem However, this sub excels in checking its arguments rem with arraydim() and arraysize() local x:local y if (arraydim(m1())<>2 or arraydim(m2())<>2 or arraydim(r())<>2) then error "Need two dimensional arrays as input" endif y=arraysize(m1(),1):x=arraysize(m1(),2) if (arraysize(m2(),1)<>y or arraysize(m2(),2)<>x) then error "The two matrices cannot be added elementwise" endif if (arraysize(r(),1)<>y or arraysize(r(),2)<>x) then error "The result cannot be stored in the third argument" endif local xx:local yy for xx=1 to x for yy=1 to y r(yy,xx)=m1(yy,xx)+m2(yy,xx) next yy next xx end sub See also arraydim and dim. _________________________________________________________________Name asc() - accepts a string and returns the position of its first character within the ascii charsetSynopsisa=asc(char$)Description The asc-function accepts a string, takes its first character and looks it up within the ascii-charset; this position will be returned. The asc-function is the opposite of the chr$-function. There are valid uses for asc, however, comparing strings (i.e. to bring them into alphabetical sequence) is not among them; in such many cases you might consider to compare strings directly with <, = and > (rather than converting a string to a number and comparing this number).Exampleinput "Please enter a letter between 'a' and 'y': " a$if (a$<"a" or a$>"y") print a$," is not in the proper range":endprint "The letter after ",a$," is ",chr$(asc(a$)+1) See also chr$ _________________________________________________________________Name asin() - returns the arcus sine of its numeric argumentSynopsisangle=asin(x)Description acos is the arcus sine-function, i.e. the inverse of the sin-function. Or, more elaborate: It Returns the angle (in radian, not degree !), which, fed to the sine-function will produce the argument passed to the asin-function.Exampleprint asin(0.5),asin(sin(pi)) This will print 0.523599 -2.06823e-13 which is pi and almost 0 respectively.See also sin, acos _________________________________________________________________Name at() - can be used in the print-command to place the output at a specified positionSynopsisclear screen...print at(a,b)print @(a,b)Description
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -