General requirements to 1C:Enterprise script clauses





This article describes the requirements to 1C:Enterprise script clauses. All of the listed recommendations are mandatory unless noted otherwise.

1. Use the canonical capitalization (as in the documentation and Syntax Assistant).

Correct:

EndIf

Incorrect:

endIf
ENDIF
endif
Endif

2. In a block of several assignment operators the following alignment is acceptable:

SelectionDialog.FullFileName = FileName;
SelectionDialog.Directory = PathName;
SelectionDialog.Title = NStr("en = 'Select the file with the list of queries'");
SelectionDialog.Filter = NStr("en = 'Query files (*.sel)|*.sel|All files (*.*)|*.*'");
SelectionDialog.DefaultExt = "sel";

You do not have to align the operators throughout the entire module. We recommend that you align the operators located next to each other.

3. Wrap compound logical expressions within If...EndIf according to the expression wrapping rules.

4. To check the result of a function that returns a logical expression, do not use comparisons with logical constants.

Correct:

If IsNew() Then

Incorrect:

If IsNew() = True Then

5. To compare expression results, first assign the results to auxuliary variables, and then compare those variables.

Correct:

Answer = DoQueryBox(NStr("en = 'The data is not saved. Do you want to save it?'"),
    QuestionDialogMode.YesNo, , DialogReturnCode.Yes);
If Answer = DialogReturnCode.Yes Then
    Write();
Else
    Return;
EndIf;

Incorrect:

If DoQueryBox(NStr("en = 'The data is not saved. Do you want to save it?'"), 
    QuestionDialogMode.YesNo, , DialogReturnCode.Yes) = DialogReturnCode.Yes Then
    Write();
Else
    Return;
EndIf;

6. Use the system value sets whenever possible. For example, use Chars.LF instead of Char(10).

See also:


Comments
0
Add comment