1C syntax

Lecture



1C syntax
A beginner programmer approaches a hacker and shows a program in BASIC.
- Tell me, please, what is my mistake?
“In DNA,” the hacker sighs.

Language 1C is very similar to BASIC. In 1C, all keywords can be written in Russian.

The design of the language 1C

Note

Procedure Calculate Tax (Employee, SomeDate)

EndProcedure

Simple procedure. After the word EndProcedure, a semicolon is not needed, because it is not an operator, but an operator bracket

Function Calculate Tax (Employee, Some Data)

Return Tax;

End Function

The function must return a result.

If Salary> 10,000 Then
...... Result = "Normal";
Otherwise
...... Result = "Bad";
End If ;

Simple condition. After the word EndIf there must be a semicolon, because the statement ends If

Result = ? (Salary> 10,000, "Normal", "Poor"); Abbreviated If.
If Salary> 10,000 Then
...... Result = "Normal";

Otherwise Salary> 5000 Then
...... Result = "Average";

Otherwise
...... Result = "Bad";
End If ;
Plural condition. If the first condition is not met, then the second is checked. If the second condition is not satisfied, then the third. If none of the conditions is met, then the Else block is executed.

If (Salary> 10,000) AND (CategoryCode = 2) Then

End If ;

In composite logical expression, parentheses are required!

Bye Number <= 50 Cycle

End of Cycle ;

Simple cycle Bye (cycle with an unknown number of repetitions). After the word EndCycle should be a semicolon, because the statement ends so far.
For Number = 1 By 50 Cycle

End of the Cycle ;

Simple For loop (loop with known number of repetitions).

Go ~ label;

<...>

~ label:

This is how labels and the unconditional branch statement (GOTO) are made. The less tags you have in your program, the better.

While Cycle

If Then
........ Continue ;
End If;

End of Cycle;

Operator Continue transfers control to the beginning of the loop.

While Cycle

If Then
......... Abort ;
End If;

End of Cycle;

Operator Abort produces an early exit from the loop. Control is transferred to the operators after the cycle.
Perem Sotr; Explicit declaration of a variable.
Number = 1; Variables may not be explicitly declared. When you first assign a value, a new variable is created.
Name = Last Name + "" + First Name + "" + Patronymic; String addition (concatenation)
SomeDate = '01 .01.2002 '; The variable that stores the date.
Move Current Customer Export ; Global variable declaration in the Global module. Such variables are available anywhere in the configuration.

Attempt

a = 10/0;

An exception

Warning ("Divide by Zero!");

EndTries ;

Exception handling.

If an error occurred during the execution of statements between the words Attempt and Exclusion, then control is transferred to the statements between the words Exception and End.

If there was no error, then control is transferred to the operators after the word EndTry.

// this is a comment So comments are made out.
Ref. Cont. Select Items (); The method of the object is called as usual, through a point.
created: 2014-09-30
updated: 2021-10-06
132731



Rating 9 of 10. count vote: 2
Are you satisfied?:



Comments


To leave a comment
If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Programming Languages and Methods / Translation Theory

Terms: Programming Languages and Methods / Translation Theory