Visual Basic Form SET_236B.frm
'Process related Types
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
'Process related functions
Private Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, _
ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal _
lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal _
dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal _
lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Sub pbCallForm_Click()
'cmdline$ = "C:\LANSA\X_WIN95\X_LANSA\execute\X_RUN LANG=XXX PART=XXX USER=XXXXXX DBID=XXXXXXX DBUT=XXXXXXXXXX DBUS=XXX PSPW=XXX FORM=S_236FB TPTH=XXX"
cmdline$ = S_cmdline.Text
'Extract the path for temporary files - this is where the .CSV files containing
'exchange data will be stored in this example, although any directory known to
'both the VB and VL application would do.
StartPos% = (InStr(cmdline$, "TPTH=")) + 5
TempPath$ = Mid$(cmdline$, StartPos%)
'Write exchange data to a csv file
'1 Open the file
' Get Input Parameters file with input suffix
m_ParmsFile = TempPath$ & "S_236FB_I.csv"
'Get unused file number
m_FileNumber = FreeFile
'Create/Open Output Parameters file
Open m_ParmsFile For Output As #m_FileNumber
'2 Write the passed data to the file
Write #m_FileNumber, "EMPNO", "A", S_Empno.Text
Write #m_FileNumber, "SALARY", "N", S_Salary.Text
Write #m_FileNumber, "STD_TEXT", "A", S_STD_TEXT.Text
'3 Close the file
Close #m_FileNumber
'Start the Visual LANSA program and wait for it to finish
'This procedure and its related definitions have been copied from:
'http://www.kather.net/VisualBasicSource/VBTips/173.txt
' courtesy of Kather Produkties
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim X As Long
NameStart.cb = Len(NameStart)
X = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc)
X = WaitForSingleObject(NameOfProc.hProcess, -1&)
X = CloseHandle(NameOfProc.hProcess)
'Read the data passed back
'1 Open file
sParmsFile = TempPath$ & "S_236FB_O.csv"
iParmsFile = FreeFile
Open sParmsFile For Input As #iParmsFile
'2 Read File until Parameter found or EOF
Do
Input #iParmsFile, sPName, sPType, sPValue
If sPName = "SALARY" Then
S_Salary.Text = sPValue
End If
If sPName = "STD_TEXT" Then
S_STD_TEXT.Text = sPValue
End If
Loop Until EOF(iParmsFile)
'3 Close the file
Close #i_ParmsFile
End Sub
Private Sub pbClose_Click()
'Close vb program
Unload Me
End Sub
Private Sub S_cmdline_Change()
If Trim$(S_cmdline.Text) = "" Then
pbCallForm.Enabled = False
Else
pbCallForm.Enabled = True
End If
End Sub
'Process related Types
Private Type STARTUPINFO
cb As Long
lpReserved As String
lpDesktop As String
lpTitle As String
dwX As Long
dwY As Long
dwXSize As Long
dwYSize As Long
dwXCountChars As Long
dwYCountChars As Long
dwFillAttribute As Long
dwFlags As Long
wShowWindow As Integer
cbReserved2 As Integer
lpReserved2 As Long
hStdInput As Long
hStdOutput As Long
hStdError As Long
End Type
Private Type PROCESS_INFORMATION
hProcess As Long
hThread As Long
dwProcessID As Long
dwThreadID As Long
End Type
'Process related functions
Private Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean
Private Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, _
ByVal dwMilliseconds As Long) As Long
Private Declare Function CreateProcessA Lib "kernel32" (ByVal lpApplicationName As Long, _
ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal _
lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal _
dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal _
lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, _
lpProcessInformation As PROCESS_INFORMATION) As Long
Private Sub pbCallForm_Click()
'cmdline$ = "C:\LANSA\X_WIN95\X_LANSA\execute\X_RUN LANG=XXX PART=XXX USER=XXXXXX DBID=XXXXXXX DBUT=XXXXXXXXXX DBUS=XXX PSPW=XXX FORM=S_236FB TPTH=XXX"
cmdline$ = S_cmdline.Text
'Extract the path for temporary files - this is where the .CSV files containing
'exchange data will be stored in this example, although any directory known to
'both the VB and VL application would do.
StartPos% = (InStr(cmdline$, "TPTH=")) + 5
TempPath$ = Mid$(cmdline$, StartPos%)
'Write exchange data to a csv file
'1 Open the file
' Get Input Parameters file with input suffix
m_ParmsFile = TempPath$ & "S_236FB_I.csv"
'Get unused file number
m_FileNumber = FreeFile
'Create/Open Output Parameters file
Open m_ParmsFile For Output As #m_FileNumber
'2 Write the passed data to the file
Write #m_FileNumber, "EMPNO", "A", S_Empno.Text
Write #m_FileNumber, "SALARY", "N", S_Salary.Text
Write #m_FileNumber, "STD_TEXT", "A", S_STD_TEXT.Text
'3 Close the file
Close #m_FileNumber
'Start the Visual LANSA program and wait for it to finish
'This procedure and its related definitions have been copied from:
'http://www.kather.net/VisualBasicSource/VBTips/173.txt
' courtesy of Kather Produkties
Dim NameOfProc As PROCESS_INFORMATION
Dim NameStart As STARTUPINFO
Dim X As Long
NameStart.cb = Len(NameStart)
X = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, NORMAL_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc)
X = WaitForSingleObject(NameOfProc.hProcess, -1&)
X = CloseHandle(NameOfProc.hProcess)
'Read the data passed back
'1 Open file
sParmsFile = TempPath$ & "S_236FB_O.csv"
iParmsFile = FreeFile
Open sParmsFile For Input As #iParmsFile
'2 Read File until Parameter found or EOF
Do
Input #iParmsFile, sPName, sPType, sPValue
If sPName = "SALARY" Then
S_Salary.Text = sPValue
End If
If sPName = "STD_TEXT" Then
S_STD_TEXT.Text = sPValue
End If
Loop Until EOF(iParmsFile)
'3 Close the file
Close #i_ParmsFile
End Sub
Private Sub pbClose_Click()
'Close vb program
Unload Me
End Sub
Private Sub S_cmdline_Change()
If Trim$(S_cmdline.Text) = "" Then
pbCallForm.Enabled = False
Else
pbCallForm.Enabled = True
End If
End Sub