ZX Format #07
05 декабря 1997 |
|
Programmers - Basic - 7: The End of the description of Beta-Basic.
Teams BB. (End) music by MIDISOFT (C) D. Rudovsky _______________________________ In this article I will complete the description of BB and I will give some tips on using it. OS Spectrum has its own internal clock, ie variable that stores the number of the fiftieth of a second (interrupts), who came from the time the computer. Advertisement BB decided to use this opportunity to arrange hours in the program. Team CLOCK "string" - allows you to set the current time, as well as set the alarm. To set the alarm the first character in the string must be the symbol A (alarm - wake up.). The string should be entered as: "Hh: mm: ss" for seconds, not alarm indicated. To use the Alarm ka additionally introduced the format: CLOCK n, where: n = 0 - do not show the testimony, an alarm clock disable; n = 1 - indicate the time in the upper right corner screen, turn off the alarm; n = 2 - the time skip, to give sound kovoy signal an alarm clock; n = 3 - specify the time and the issue of sound kovoy signal an alarm clock; n = 4 - does not specify a time for tripping Vania alarm switch to strictly ku; n = 5 - similar to n = 4, with the withdrawal time on the screen; n = 6 - similar to n = 4 with the issue of sound Vågå signal before the transition; n = 7 - n = 5 and n = 6 together; n = 8 .. 9999 - set the line number which will be made re progress when the alarm. Example: 10 PRINT "346 * 789 =?" 20 CLOCK "00:00:00": CLOCK "A00: 01" 1930 1000 CLOCK: CLOCK 7 F 40 INPUT X 50 IF X = 346 * 789 THEN PRINT "Very Good!" ELSE "Bad rezult!": GO TO 40 F 60 0 CLOCK 70 STOP F1000 CLOCK 0 1010 PRINT "No more time!" 1020 STOP Legend: At 20 bar we set the system clock to 0 and the alarm set for 1 minute. At 30 bar we set the line of transition and operation hours (see above). Then we ask for input of numbers and if the result is true, and it took less than a minute then we obtain the inscription "Very Good", clock would be placed in a passive state ( Line 60) and the program will stop. If the result is false, but yet there, then displays a message will transition back to the line 40. If time expires, then regardless the result will be given a sound and will move to line 1000. WARNING! Go to the alarm clock is only after all! current line. Also, this mode does not work during editing. The SORT command is used to sort arrays and character strings. Its format is: SORT [INVERSE] var, where: INVERSE - optional, indicated cates the condition of toilets ki, ie, if you have one litter Adjustments will occur on descending order, otherwise, to ascending; var - the name of the array or string. Sort going to symbolical arrays for the first character by default. To sort by another character uses a design: SORT S $ () (N TO), where: S $ - character array; N - number of characters that will be produced by sorting. To sort an array of uses: SORT S $ (N TO M), where: N, M - border sorting. Example: 10 DIM a $ (100,10) 20 FOR I = 1 TO 100 30 FOR J = 1 TO 10 40 LET A $ (I, J) = CHR $ (RND * 25 +65) 50 NEXT J: PRINT A $ (I) 60 NEXT I 70 PRINT "Sorting for 1st char:" SORT A $ 80 90 FOR I = 1 TO 100 100 PRINT A $ (I) 110 NEXT I 120 PRINT "Sorting for 2st char:" 130 SORT A $ () (2 TO) 140 FOR I = 1 TO 100 150 PRINT A $ (I) 160 NEXT I 170 STOP On it I finish the description of the commands BB given in the end help for relevance Keys and commands (all commands are typed in pseudographics mode): [A] - ALTER [6] - AUTO [C] - CLOCK [1] - DEF KEY [1] - DEF PROC [7] - DELETE [D] - DO [P] - DPOKE [0] - EDIT [E] - ELSE [3] - END PROC [I] - EXIT IF [F] - FILL [G] - GET [CS] + [6] - JOIN [CS] + [6] - KEYIN [8] - KEYWORDS 0 [9] - KEYWORDS 1 [L] - LOOP [O] - ON [N] - ON ERROR [Q] - POP [2] - PROC [9] - RENUM [R] - ROLL [S] - SCROLL [M] - SORT [T] - TRACE [P] - USING Options BB. Besides additional commands BB offers several new features that are introduced as well as usual, is determined user, but are perceived by WB, as internal. All functions can be divided into three groups: logic, math and others. By logical functions include: AND (n, m) [FN A (] - logical AND; OR (n, m) [FN O (] - logical OR; XOR (n, m) [FN X (] - XOR. By mathematical functions include: a) The functions convert formats: . BIN $ (n) [FN B '& (] - transformation of the Tenth mean-square of a binary ary line; DEC (string) [FN D (] - transformation line containing hexadecimal numbers Lo, in decimal. - HEX $ (n) [FN H (] - transformation of the Tenth tichnogochislav hex line; - USING $ (format, number) [FN U $ (] - sign- curve in record numbers specified format. b) enhanced standard features: . COSE (n) [FN C (] - faster and more rough version cos; SINE (n) [FN S (] - analog. For sin; DPEEK (n) [FN P (] - the same way: 256 * PEEK (N +1) + PEEK (N); RNDM (n) [FN R (] - the same way: n * RND. The remaining functions are functions determine the amount of memory contents screen, etc. CHAR $ (n) [FN C $ (] - converting numbers la in the range 0-65535 the equivalent row Since the two characters; FILLED () [FN F (] - the number of elements images, filled United latest to executing FILL; INSTRING (n, Row1, Row2) [FN I (] - return schaet position of the first the sign of line 2 at viewing line 1, starting with a given starting position. If the inside of row 1 no line 2, then returns 0. MEM () [FN M (] - returns the amount of free the free memory; MEMORY $ () [FN M $ (] - returns the value of all the memory from 0 65535 interpreted synchronize, as one string; MOD (n1, n2) [FN V (] - returns the remainder dividing n1 by n2; NUMBER (string) [FN N (] - transformation string of two characters a two-byte number, where every byte of Keep the number corresponding to yuschee given code ASCII; SCRN $ (y, x) [FN K $ (] - returns the sign located on the screen in a given position; STRING $ (n, string) [FN S $ (] - repeats string specified number honors again; TIME $ () [FN T $ (] - returns a string soderzhaschuyutekuschee time. Features programmirvaniya in BB. Extending the capabilities of the standard BASIC, WB revises and programming methods themselves, so when working in BB desirable to consider the following points: 1) As a result of changes in the action of FOR ... NEXT speed of its execution increases significantly when working with integers in the range 0 .. 65535, so try to do integral cycle. 2) The emergence of the procedures and associated local variables appeared to significantly save memory by localizing variables. It also allows you to move to the concept of structuring the program. 3) Having the opportunity to Rich O, and the introduction of windowing an orderly display of necessary information. 4) Team Sorting allows for more effective use of WB in organizaii databases. _______________________________
Other articles:
Similar articles:
В этот день... 21 November