Home > other >  Cosine basis introduction
Cosine basis introduction

Time:09-16

A, the basic command
COS command is not much, we first introduce the most commonly used, note: all COS command case-insensitive, most are abbreviations at the same time, since the cosine is strongly typed, so we don't need to declare variables in advance, we will start setting variables:
-- -- -- -- -- - set variable
SET is ordered to SET variables, abbreviated as S, syntax for the SET x=value,
For example, in the Terminal execution
The Set x="Hello, World"
If need will gives a lot of variables to the same value at the same time, this is something you can Set (x, y, z)=value:
Set (x, y, z)="yes"
Sometimes, you will see written as: Set x=value1, y=value2, this is the abbreviation, is equal to
The Set x=value1
The Set y=value2
-- -- -- -- -- - the output
The WRITE command will output the result to the current equipment, abbreviated as W, grammar to WRITE x,
For example, in the Terminal execution
The Set x="Hello, World"
The Write x
Can also be output more than one variable at a time, with between variables, segmentation, such as
, "Write" The value is, The x
Although the WRITE command are seldom used in object-oriented programming in the future, but when debugging is very common,
Need to the results according to the format of the output, you can join control characters, such as! #? Etc.,! Said the enter, brush # said new screen,? Followed by a column Numbers in the output,
In the Terminal execution
Write "Current is,"! ,? 15, $ZT ($ZTS)
-- -- -- -- -- - execute code
DO is used to execute code, abbreviated as D, grammar to DO routine, example
For example, in the Terminal execution
Do $System. OBJ. ShowObjects (" d ")


-- -- -- -- -- - the IF judgment
IF judgment, abbreviated as I, grammar is:
IF expression1 {
...
} ELSEIF expression2 {
...
} ELSE {
...
}
For example, in the Terminal execution
If 2=1 "2=1" {w} else {w "2 & lt;> 1}
"-- -- -- -- -- - FOR loop
The abbreviation of the For loop to F, syntax For the
FOR start: increment: end {...}, start said loop variable initial value, increment said enzyme increment, each loop variable loop variable values at the end said out,
For example, in the Terminal execution
I, FOR I=2:1:10 {w! }
Sometimes, you will see that there is no end For loop conditions, then you need to specify the exit criteria,
In the example below when I will quit more than 10 cycle:
FOR I=1:1 {if i> {the quit 10} else {w I,! }}
-- -- -- -- -- - WHILE loop
The While loop not abbreviated, grammar is:
WHILE expression,... {}
For example, in the Terminal execution
The Set y=1 WHILE y & lt; 10 {Set + 1 WRITE y, y=y! }
-- -- -- -- -- - to terminate execution
The QUIT is terminate execution command, abbreviated as Q, can take return parameter, grammar is:

The QUIT expression
-- -- -- -- -- - conditional execution
As the name suggests to satisfy conditions after the implementation, often can see the command syntax: (expression),
Such as Set (x=1) y=2, the grammar is when expression expression is True, perform corresponding command is the same as
If (expression) command,
So
The Set (x=1) y=2
Equal to
If (x=1) {set y=2}
2, operator
Cosine operator mainly divided into three classes: arithmetic operators, logical operators, string operator, here is the commonly used operators,
Note that the operator in the COS no priority, strictly from left to right, when it is necessary to use () to separate operating sequence.
-- -- -- -- -- - arithmetic operators
Subtracting: + - */
For example, the following expressions will return to 6,
W 2 + 3 * 5-1/4
Power: * *
For example, the following expressions will return to 8,
2 * * 3 W
Divisible:/
For example, the following expression returns 0,
W two-thirds
Remainder: #
For example, the following expression returns 2,
2 # 3 W
-- -- -- -- -- - logical operators
And: & amp; & &
& And & amp; & Are operators, the difference & amp; & In the left operand immediately returns 0 to 0, and not to judge the right operand,
For example, the following expression returns 0,
W 0 & amp; & 2

Or:! | |
! And | | or operator, the difference is | | in the left operand non-zero immediately return 1, and not to judge the right operand,
For example, the following expression returns 1,
W 1 | | 0
A: '
COS is not in the 'for example, the following expression returns 0,
1
w 'Due to the operators strictly from left to right, so the following expression returns 0,
The SET x=1, y=0
The WRITE x=1! Y=0
-- -- -- -- -- - the numerical relationship between operator
More than: & gt;
For example, the following expression returns 0,
W 2 & gt; 3
Less than: & lt;
For example, the following expression returns 1,
W 2 & lt; 3
Is equal to:=
For example, the following expression returns 0,
2=3 W
Greater than or equal to: & gt;=
For example, the following expression returns 0,
W 2 & gt;=3
Less than or equal to: & lt;=
For example, the following expression returns 1,
W 2 & lt;=3
-- -- -- -- -- - string operator
A hyphen: _
For example, the following expressions will return "Hello World",
W "Hello" _ "World", "
Note that it is because the _ is a hyphen, so _ can't appear in the package name, the name of the class, the property name and method name;
But can appear in the table name, field name,
The use of the three, $
$in COS grammar, often see $sign, is a sometimes, sometimes 2 or 3 $, a brief introduction of what time will appear below $and its meaning:
$:
System provides many Cache function (function) and system variables, and they all begin with $, as we are familiar with $Piece (according to the separator to obtain or replace words
String system function); $Horolog (get the current time of system variables).

$$:
Can use the above $& lt; Function> To invoke the system function, the user can also define your own function (function), and use $$& lt; Function> To invoke the function, for example, define a function named Test in the following Routine (*. MAC), and $$to call it:
The Main
The Test () PUBLIC
The Set x="test"
W x,!
The Quit x
Testme ()
The Set y=$$Test ()
W, y!
Q
$$$:
In COS, $$$on behalf of the macro, for example, we are familiar with the $$$OK, $$$ERROR (), of course, we can also define your own macros, this example to create a macro called GETDATESTR, return date type MM - DD YYYY - string format, in the studio to the new User. MyInc. Inc file, and define macros GETDATESTR, the macro with a parameter:
# define GETDATESTR (% n) $lh-zd (% n, 3)
Can reference the macro in the other class, the method is to increase the Include in the head of the class User. MyInc,
Pay attention to don't need to add inc suffix, after, can in class method calls to the macro as follows:
ClassMethod Today ()
{
The Set y=$$$GETDATESTR ($h)
Today is: "W", y,!
}
  • Related