GetStateText

(Engine-Level Function)

Description: Returns the text for the specified state.
Warning: This function should be used only by advanced programmers.
Returns: Text
Usage: Script or steady state.
Function Groups: Compilation and On-Line Modifications,  State
Related to: AdjustCode | GetModuleText | GetOneParmText | GetParmText | GetTransitText | GetVariableText | SetModuleText | SetOneParmText | SetParmText | SetStateText | SetTransitText | SetVariableText | TextOffset | TextSize
Format: GetStateText(State, Mode)
Parameters:  
State
Required. Any expression for the code value which defines the state.
Mode
Required. Any numeric expression for the desired information:

Mode

Desired information

0

Character offset to beginning of state definition from start of module (includes state name and square brackets enclosing state code).

1

Size of state in characters, including state name and square brackets.

2

Character offset to beginning of first statement from start of state.

3

Size of state code in characters, excluding state name and square brackets.

Comments: none

Example:

  If 1 Next;
  [
    { The module and file for which to get state code }
    ModVal = FindVariable("ConfigFolder", Scope(Code,
                          "AnalogInput"), 0, 0);
    FStream = FileStream("C:\VTScada\VTS\AnalogInput.SRC");
    { Get the states and create an array in which to store their code   }
    SList = StateList(ModVal, 1);
    Num = ArraySize(SList, 0);
    CodeList = New(Num);
    I = 0;
    WhileLoop(I < Num,
              StateOffset = GetStateText(SList[I], 0) +
              GetStateText(SList[I], 2).
              StateLength = GetStateText(SList[I], 3);
      { Read in the code contained in that state - don't include the square brackets }
              Seek(FStream, GetModuleText(ModVal, 1) + StateOffset, 0);
              StateCode[I] = BuffStream("");
              BlockWrite(StateCode[I], FStream, StateLength);
              Seek(StateCode[I], 0, 0);
              I++;
            );
    CloseStream(FStream);
  ]