VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "PageString"
   ClientHeight    =   3624
   ClientLeft      =   60
   ClientTop       =   396
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   3624
   ScaleWidth      =   4680
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox TextString 
      Height          =   615
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   8
      Top             =   2880
      Width           =   4335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Set"
      Height          =   495
      Left            =   2160
      TabIndex        =   6
      Top             =   960
      Width           =   1935
   End
   Begin VB.TextBox TextLTString 
      Height          =   375
      Left            =   1920
      TabIndex        =   5
      Top             =   1920
      Width           =   2535
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Matrix"
      Height          =   495
      Index           =   3
      Left            =   360
      TabIndex        =   4
      Top             =   1320
      Width           =   975
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Data"
      Height          =   495
      Index           =   2
      Left            =   360
      TabIndex        =   3
      Top             =   840
      Width           =   975
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Graph"
      Height          =   495
      Index           =   1
      Left            =   360
      TabIndex        =   2
      Top             =   360
      Width           =   975
   End
   Begin VB.OptionButton Option1 
      Caption         =   "Notes"
      Height          =   495
      Index           =   0
      Left            =   360
      TabIndex        =   1
      Top             =   1800
      Width           =   975
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Get"
      Height          =   495
      Left            =   2160
      TabIndex        =   0
      Top             =   240
      Width           =   1935
   End
   Begin VB.Label Label2 
      Caption         =   "String"
      Height          =   255
      Left            =   360
      TabIndex        =   9
      Top             =   2640
      Width           =   1095
   End
   Begin VB.Label Label1 
      Caption         =   "LTString"
      Height          =   255
      Left            =   1920
      TabIndex        =   7
      Top             =   1680
      Width           =   1335
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Example for PageString and LTStr Orign Automation Server properties, and Execute method
'Copyright OriginLab Corporation 2003.
'
Dim text As String
Dim WndName As String, MatrName As String, PlotName As String, DataName As String, NoteName As String
Dim LTStr As String
'make sure Origin reference is checked (VB menu Project->References...)
'Dim oApp As Origin.Application 'for exclusive session
Dim obj As Origin.ApplicationSI
Private Sub ReportErrorAndExit()
    MsgBox "Unable to create window in Origin, application will end."
    Stop
End Sub

Private Sub Command1_Click()
'Get
    LTStr = TextLTString.text
    text = obj.PageString(WndName, LTStr)
    TextString.text = text
End Sub

Private Sub Command2_Click()
'Set
    LTStr = TextLTString.text
    text = TextString.text
    obj.PageString(WndName, LTStr) = text
End Sub

Private Sub Form_Load()
    'initial value for LT string - it can be edited later
    TextLTString.text = "page.label$"
    
    'Get a reference to the Origin Automation Server object
    'Set obj = GetObject("", "Origin.Application") 'for exclusive session
    Set obj = GetObject("", "Origin.ApplicationSI")
    
    'Make sure we have all types of windows in Origin,
    
    'LabTalk's %H string variable will hold the name of the last window created
    If obj.Execute("win -t matr") Then MatrName = obj.LTStr("%H") Else ReportErrorAndExit
    If obj.Execute("win -t plot") Then PlotName = obj.LTStr("%H") Else ReportErrorAndExit
    If obj.Execute("win -t data") Then DataName = obj.LTStr("%H") Else ReportErrorAndExit
    'LabTalk's function exist(notesname) can return 0 if "notesname" is undefined so
    'new Notes window with that name can be created,
    'and 9 if "notesname" is the name of existing Notes window, so there is nothing to do.
    'Any other value means this application will stop.
    'We will record the return value in LabTalk variable OAVar
    If Not obj.Execute("OAVar = exist(notename);" & _
                        "if (0==OAVar) win -n n notename ") Then ReportErrorAndExit

    'get the value of OAVar and check if it is 0 or 9
    VBVar = obj.LTVar("OAVar")
    If 9 <> VBVar And 0 <> VBVar Then ReportErrorAndExit
    NoteName = "notename"
    
    'Initialize radio buttons
    Option1.Item(1).Value = True
    WndName = PlotName
    
End Sub

Private Sub Option1_Click(Index As Integer)
    Select Case Index
    Case 0
    WndName = NoteName
    Case 1
    WndName = PlotName
    Case 2
    WndName = DataName
    Case 3
    WndName = MatrName
    Case Else
    WndName = ""
    End Select
End Sub

