GetStateText

Description:              This function returns the text for the specified state.

Warning:               For use by advanced programmers only.  Effective use of this function requires a thorough understanding of VTS programming. 

Returns:                    Text

Usage:                       Script or Steady State

Format:                      GetStateText(State, Mode)

Parameters:             State     { code value }  { required }  { no default }

                                              Any expression for the code value which defines the state.

                                    Mode     { numeric }  { required }  { no default }

                                              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:              

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:\VTS\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); 

See Also:

AdjustCode | GetModuleText | GetOneParmText | GetParmText | GetTransitText | GetVariableText | SetModuleText | SetOneParmText | SetParmText | SetStateText | SetTransitText | SetVariableText | TextOffset | TextSize