To: Winsnap Users

From: Michael F. Murphy

Date: January 23, 2001

Re: Use & Customization of Script

To all Winsnap users the following document provides insight into using this script that will scrape FMS (Financial Management System) data from the PC screen and write the data onto ones hard drive. This script has been created and programmed to conform to the appearance of data presented to Temple staff using Attachmate Extra program.

Basically this script will keep on scraping the PC screen (there are 24 rows and 80 columns on a FMS screen) until it senses a specific target and that target is the simple letters “SORT” located at position row #18 and starting in column #02 as hi-lited below. Now keeping this simple here is how the script functions:

1.The user receives their query answer set back from the mainframe computer and runs the script. The cursor is automatically located at position 01/04 (row/column respectively) & the script scraping process initiates. After the screen scrape is complete the script moves the cursor to position 02/04 and submit a carriage return to the mainframe for more screen data.

2. The script will idle with the cursor located at 02/04 until the mainframe paints the screen with fresh data and repositions the cursor to position 01/04. Once the cursor is at 01/04 it will once again fire and scrape the screen data.

3. The scraped screen data is written to the file “C:\Winsnap.txt” and each scraped screen data is appended onto this text file.

4. The script keeps looping until it senses the word “SORT” in position #18/02. Once it encounters this target the script will terminate.

Now certain Temple users will need to perform some script customization on the screen targets for their screen delivery of data is slightly different than the screen below. You will need to examine the final screen you are presented with after the conclusion of your query. Analyze the screen and select a target that will not change, and replace the script target and position with the one that works for you.

Here is a FMS screen that the script is currently geared towards:

FMS Screen image

Notice that the cursor (the small red block) is in position #23/80!

Here is the code to the Winsnap.ebm macro!

'Script name is Winsnap.EBM

Written by Michael F. Murphy

'Date of last update is January 20,1999

Declare Sub FileOpen

Declare Sub QueryControl

Declare Sub ScreenScrape

Declare Sub FileClose

Sub Main()

Call FileOpen

Call QueryControl

Call FileClose

End Sub

Sub FileOpen

Close #1

Open "C:\Winsnap.tmp" for Output as #1

End Sub

Sub QueryControl

Dim Sys As Object,Sess As Object,MyScreen As Object,MyArea As Object

Set Sys = CreateObject("EXTRA.System")

Set Sess = Sys.ActiveSession

Set MyScreen = Sess.Screen

Sys.TimeoutValue = 500 'This is 500 milliseconds (½ second)

Call ScreenScrape

MyScreen.SendKeys "<Down><Enter>"

Do

EndCheck = MyScreen.WaitForString("SORT")

If Not EndCheck then

Cursor = MyScreen.WaitForCursor (1,4)

If Cursor then

Call ScreenScrape

MyScreen.SendKeys "<Down><Enter>"

End If

End If

Loop Until EndCheck

Set Sys = Nothing

Set Sess = Nothing

Set Screen = Nothing

End Sub

Sub ScreenScrape

Dim Sys As Object,Sess As Object,MyScreen As Object,MyArea As Object

Set Sys = CreateObject("EXTRA.System")

Set Sess = Sys.ActiveSession

Set MyScreen = Sess.Screen

Dim RowNumber as Integer

For RowNumber = 3 To 23

Print #1,MyScreen.GetString(RowNumber,1,80)

Next

End Sub

Sub FileClose

Close #1

Open "C:\Winsnap.tmp" for Input as #1

Open "C:\Winsnap.txt" for Output as #2

Dim FMSRecord as String

Dim Pos1 as Integer

While TestEOF <> -1

Line Input #1, FMSRecord

Do

Pos1% = InStr(FMSRecord$,Chr$(34)) 'Chr34 is a double quote

If Pos1% then

Mid(FMSRecord$,Pos1%,1) = Chr$(32) 'Chr32 is a space

End If

Loop Until Pos1% = 0

Print #2, FMSRecord

TestEOF = EOF(1)

Wend

Close #1

Close #2

Kill "C:\Winsnap.tmp"

TextA = "The Query answer set has been written to C:\Winsnap.TXT ." & Chr(10)

TextB = "The file only contains the query answer set lines as displayed on screen."

TextC = "The data is in text format and NOT parsed !"

TotalText = TextA & Chr(10) & Chr(10) & TextB & Chr(10) & Chr(10) & TextC

MsgBox TotalText,64,"Created by Michael F. Murphy"

End Sub