Rifat писал(а):
Какие комментарии перед функциями используете?
Пишете ли комментарий в произвольной форме или же там есть определенный набор полей, например: назначение функции, параметры, выходной результат? Какие еще поля используете в комментарии?
Я в комментариях описываю, что функция делает с каждым из параметров, и каковы их допустимые значения/диапазоны и особые случаи/комбинации значений. Иногда это умещается в одно предложение, иногда каждый из параметров приходится расписывать. Аналогично с выходным значением. Редко приходится отдельно описывать поведение фукнции (например, не возвращает управление, пока не случится то-то).
Код:
Sub SetRowReadOnly (Byval row As Integer, Byval columnUseMap As String)
' Set read-only status for all cells of the row according to the
' columnUseMap. Where the map contains " ", that cell is not in use, and
' must be read-only.
Код:
Function RowToTank (Byval row As Integer) As Integer
' Convert ugDevices row number into tank number. This shall be used if and
' when we use multiple rows of ugDevices to configure one tank in ugTankCfg.
' PRE: 0 <= row < ugDevices.GetNumberRows
' POST: 0 <= result < maxNumTanksSupported
Код:
Function GetLastNonEmptyTankIndex As Integer
' Return the index of the last tank that has at least one device assigned: 0..maxNumTanksSupported-1
' If all tanks are empty, then return -1.
Код:
Function FindSlaveTankPos (Byval slaveType As String, Byval slaveAddr As Integer) As Integer
' Find the first tank position that contains the slave of type slaveType with
' address slaveAddr. Return the tank position number if found, -1 otherwise.
' slaveType is one of ("REX", "RTG", "PRO", "IDAU", "SDAU", "R2410", "Enraf", "Whessoe"),
' otherwise return -1.
' If (slaveAddr <= 0), then return -1, i. e. don't search for non-existing devices.
Код:
Function UpdateSlaveDSFields () As Boolean
' Use data in DataCtx.Variable("POS_DEVICE_ADDR" & Pos) and
' DataCtx.Variable("POS_BUDDY_DEVICE_ADDR" & Pos) to detect slave devices that
' were moved to a new tank position. If there are such devices, use the
' DevCommon.SRF_DS_SETUP (or DevEnraf.csr:SRF_ENRAF_DB_R2460 for Enraf devices)
' to update the slave's DS- and MS-fields. For 2410 tank positions we show a
' warning dialog to make user update their settings.
' Return True if data saved successfully, or False if abort is needed.