Class CountingNCWord
The special case of the NumericNCWord which automatically increments (or decrements) the value of the register with the defined step after each call of Out() or Form().
The most useful application of this kind of register is blocks or lines numbering case.
Inherited Members
Namespace: DotnetPostprocessing.SDK
Assembly: DotnetPostprocessing.SDK.dll
Syntax
public class CountingNCWord : NumericNCWord
Constructors
CountingNCWord(string, double, double, int, bool)
Creates a new instance of the CountingNCWord and initializes it with the specified set of parameters.
It is used the "format"
string parameter to define the all formatting rules
for the NumericNCWord.
For example, the "format"
parameter can be: "X = {-####!0##};".
The formatting rules are below.
- The curly braces divide the expression into three parts.
- Anything to the left of the braces is assigned to the Address property and passed to the output line unchanged (here is "X = ").
- Anything to the right of the braces is assigned to the TailString property and also goes to the output string as it is (here is ";").
- The expression inside the braces defines the formatting rules applied to the current v value (here is "-####!0##"). It can only include these characters "-+.!_#0".
- If the first character in braces is "-", then the sign of the number will output only for negative numbers. It corresponds to SignMode property value Minus.
- If the first character in braces is "+", then the sign of the number will output both for positive and negative numbers. It corresponds to SignMode property value PlusAndMinus.
- If the first character in braces is not "+" or "-", then the sign of the number will not output at all. It corresponds to SignMode property value No.
- One of the characters ".!_" in curly braces separates the integer part from the fractional part and determines how to output the decimal point.
- The point "." means the optional output, so the decimal point will output for fractional numbers, and for integers it will be skipped. It corresponds to the property PointMode = No.
- An exclamation point "!" indicates a required output, so the decimal point will output both for fractional and integer numbers. It corresponds to the property PointMode = Always.
- The underscore "_" or the absence of any of the characters ".!_" at all means that the decimal point will never be output. It corresponds to the property PointMode = No.
- The number of characters "0" or "#" before the characters ".!_" indicates the number of characters allowed before the decimal point. It corresponds to the property DigitsBeforePoint.
- If at least one of the characters before the point is zero "0", then non-significant zeros are required. It corresponds to the property LeadingZeroes = true.
- If all characters before the point are "#", then non-significant zeros will not output. It corresponds to the property LeadingZeroes = false.
- The number of characters "0" or "#" after the characters ".!_" indicates the number of characters allowed after the decimal point. It corresponds to the property DigitsAfterPoint. The number will be rounded to the specified number of digits before output.
- If all characters after the point are "#", then non-significant zeros will not output. It corresponds to the property TrailingZeroes = No.
- If all characters after the point are "0", then non-significant zeros are required. It corresponds to the property TrailingZeroes = Yes.
- If the first character after the point is "0" and the rest are "#", then only first non-significant zero will output and the rest will be skipped. It corresponds to the property TrailingZeroes = OneOnly.
Declaration
public CountingNCWord(string format, double defaultValue, double AutoIncrementStep, int outFrequence, bool preserveIndent)
Parameters
Type | Name | Description |
---|---|---|
string | format | The string that defines the formatting rules for the NumericNCWord. For example: "X = {-####!0##};". See description of the constructor for more details. |
double | defaultValue | The parameter to define a default value for the NumericNCWord. It is used to assing initial values to the current v and the previous v0 values just after creation of the NumericNCWord or when you call RestoreDefaultValue(bool) method manually. |
double | AutoIncrementStep | The numerical step that automatically will be added to the v current value of the register after the each call of Out() or Form() methods. |
int | outFrequence | Default value for the Frequence property that means the count of iteration (calls of Out() or Form() methods) after which the register will output the value instead of skipping it. |
bool | preserveIndent | Default value for the PreserveIndent property that tries to preserve indentation when register's output is skipped due to Frequency property is greater than 1. |
CountingNCWord(string, double, double, int)
Creates a new instance of the CountingNCWord and initializes it with the specified set of parameters.
It is used the "format"
string parameter to define the all formatting rules
for the NumericNCWord.
For example, the "format"
parameter can be: "X = {-####!0##};".
The formatting rules are below.
- The curly braces divide the expression into three parts.
- Anything to the left of the braces is assigned to the Address property and passed to the output line unchanged (here is "X = ").
- Anything to the right of the braces is assigned to the TailString property and also goes to the output string as it is (here is ";").
- The expression inside the braces defines the formatting rules applied to the current v value (here is "-####!0##"). It can only include these characters "-+.!_#0".
- If the first character in braces is "-", then the sign of the number will output only for negative numbers. It corresponds to SignMode property value Minus.
- If the first character in braces is "+", then the sign of the number will output both for positive and negative numbers. It corresponds to SignMode property value PlusAndMinus.
- If the first character in braces is not "+" or "-", then the sign of the number will not output at all. It corresponds to SignMode property value No.
- One of the characters ".!_" in curly braces separates the integer part from the fractional part and determines how to output the decimal point.
- The point "." means the optional output, so the decimal point will output for fractional numbers, and for integers it will be skipped. It corresponds to the property PointMode = No.
- An exclamation point "!" indicates a required output, so the decimal point will output both for fractional and integer numbers. It corresponds to the property PointMode = Always.
- The underscore "_" or the absence of any of the characters ".!_" at all means that the decimal point will never be output. It corresponds to the property PointMode = No.
- The number of characters "0" or "#" before the characters ".!_" indicates the number of characters allowed before the decimal point. It corresponds to the property DigitsBeforePoint.
- If at least one of the characters before the point is zero "0", then non-significant zeros are required. It corresponds to the property LeadingZeroes = true.
- If all characters before the point are "#", then non-significant zeros will not output. It corresponds to the property LeadingZeroes = false.
- The number of characters "0" or "#" after the characters ".!_" indicates the number of characters allowed after the decimal point. It corresponds to the property DigitsAfterPoint. The number will be rounded to the specified number of digits before output.
- If all characters after the point are "#", then non-significant zeros will not output. It corresponds to the property TrailingZeroes = No.
- If all characters after the point are "0", then non-significant zeros are required. It corresponds to the property TrailingZeroes = Yes.
- If the first character after the point is "0" and the rest are "#", then only first non-significant zero will output and the rest will be skipped. It corresponds to the property TrailingZeroes = OneOnly.
Declaration
public CountingNCWord(string format, double defaultValue, double AutoIncrementStep, int outFrequence)
Parameters
Type | Name | Description |
---|---|---|
string | format | The string that defines the formatting rules for the NumericNCWord. For example: "X = {-####!0##};". See description of the constructor for more details. |
double | defaultValue | The parameter to define a default value for the NumericNCWord. It is used to assing initial values to the current v and the previous v0 values just after creation of the NumericNCWord or when you call RestoreDefaultValue(bool) method manually. |
double | AutoIncrementStep | The numerical step that automatically will be added to the v current value of the register after the each call of Out() or Form() methods. |
int | outFrequence | Default value for the Frequence property that means the count of iteration (calls of Out() or Form() methods) after which the register will output the value instead of skipping it. |
CountingNCWord(string, string, NCWordSign, NCWordDecPoint, int, int, double, double, int, bool)
Creates a new instance of a CountingNCWord register with the given parameters.
Declaration
public CountingNCWord(string address, string tailString, NCWordSign signMode, NCWordDecPoint pointMode, int digitsBefore, int digitsAfter, double defaultValue, double AutoIncrementStep, int outFrequence, bool autoUpdateState)
Parameters
Type | Name | Description |
---|---|---|
string | address | Address - start part of the register's output string. |
string | tailString | TailString - final part of the register's output string. |
NCWordSign | signMode | SignMode - defines how to output the sign of the number. |
NCWordDecPoint | pointMode | PointMode - defines how to output the decimal point of the number. |
int | digitsBefore | DigitsBeforePoint - count of digits before decimal point of the number. |
int | digitsAfter | DigitsAfterPoint - count of digits after decimal point of the number. |
double | defaultValue | DefaultValue - default value of the register. |
double | AutoIncrementStep | The numerical step that automatically will be added to the v current value of the register after the each call of Out() or Form() methods. |
int | outFrequence | Default value for the Frequence property that means the count of iteration (calls of Out() or Form() methods) after which the register will output the value instead of skipping it. |
bool | autoUpdateState | AutoUpdateState - determines whether the State should be automatically updated when the current v or previous v0 value changes. |
Fields
fFrequenceCounter
The counter for the Frequence property.
Declaration
protected int fFrequenceCounter
Field Value
Type | Description |
---|---|
int |
Properties
AutoIncrementStep
Declaration
public double AutoIncrementStep { get; set; }
Property Value
Type | Description |
---|---|
double |
Frequence
The number of Out() or Form() method calls after which the register will be included in the output line of the NCBlock, and will not be skipped. If it is one then it will be presented in each output. If it is two then it will be presented in each second output etc.
Declaration
public int Frequence { get; set; }
Property Value
Type | Description |
---|---|
int |
FrequenceReached
This property is "true" only if the Frequence counter has reached the limit value and the value of this CountingNCWord will be presented in the next call of Out() or Form() methods.
Declaration
public bool FrequenceReached { get; }
Property Value
Type | Description |
---|---|
bool |
PreserveIndent
If this property is "true" then when the Frequence of the CountingNCWord is more than 1 and when the value of this register will be skipped then it will form spaces instead of the actual value of the register to preserve indents in the output line of the NCBlock.
Declaration
public bool PreserveIndent { get; set; }
Property Value
Type | Description |
---|---|
bool |
Methods
Init()
This method initializes an internal state of the CountingNCWord just after creation.
Declaration
protected override void Init()
Overrides
ResetFrequenceCounter()
Resets the internal counter of the Frequence property to the default state to start the counting again.
Declaration
public void ResetFrequenceCounter()