Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Variables in a Dialog Box 2

Status
Not open for further replies.

jrcampb

Programmer
Apr 9, 2012
11
US
I have a macro that is reading data from attachmate and setting variables based on the data found. I could do it as an integer or string, either would work for me.

For example:

if (Sess0.Screen.getstring(2, 2, 2) = "12") then
iVA = 1

Else
iVA = 0


I want to pop a dialog box that shows the result of these searches. I'm not sure how to display the contents of a variable in a dialog box. Basically I need it to say "YES" or "NO" for about 15 categories.

Thanks!
 


hi,
Code:
select case Sess0.Screen.getstring(2, 2, 2) 
  case "12", "22", "32"  'your 15 categories
      iVA = 1
  Case else
      iVA = 0
end select

msgbox iVA
Don't know where you get "YES" or "NO" unless "YES" is 1 and "NO" is 0.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Skip,

I'm checking 15 different areas on 15 different screens. I have it sent to integer right now, but I'm going to swap it to string "yes" vs "no" later.

Is there a way to show all of them at once in the same box?

It may meet multiple criteria and need to know the best way to show the results of all 15 things being checked at once.

Thank you!

For example a larger portion:
Code:
        if (Sess0.Screen.getstring(9, 4, 1) = "Y") then
            iRepurchase = 1
        
        Else
            iRepurchase = 0
        
        end if
        
        if (Sess0.Screen.getstring(15, 71, 2) = "WO") then
            iWellsOwned = 1
        
        Else
            iWellsOwned = 0
        
        end if
        
        if (Sess0.Screen.getstring(12, 51, 7) = "HEOWNED") then
            iCoLoss = 1
        
        Else
            iCoLoss = 0
        
        end if
        
        if (Sess0.Screen.getstring(12, 51, 7) = "CLWOWE2") then
            iCoLoss = 1
        
        Else
            iCoLoss = 0
        
        end if
        
        if (Sess0.Screen.getstring(15, 71, 6) = "WOEPBO") then
            iWOEPBO = 1
        
        Else
            iWOEPBO = 0
        
        end if
        
        if (Sess0.Screen.getstring(15, 71, 6) = "WOEBPO") then
            iWOEPBO = 1
        
        Else
            iWOEPBO = 0
        
        end if
        
        if (Sess0.Screen.getstring(15, 71, 5) = "WORSI") then
            iRSI = 1
        
        Else
            iRSI = 0
        
        end if        
        
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        Sess0.Screen.sendkeys("<Home>DLQ1<Enter>")	
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        
        if (Sess0.Screen.getstring(2, 39, 1) = "R") then
            iREO = 1
        
        Else
            iREO = 0
        
        end if
        
        if (Sess0.Screen.getstring(2, 39, 1) = "B") then
            iBK = 1
        
        Else
            iBK = 0
        
        end if  
        
        if (Sess0.Screen.getstring(2, 41, 2) = "CO") then
            iChargeOff = 1
        
        Else
            iChargeOff = 0
        
        end if 
        
        if (Sess0.Screen.getstring(2, 2, 2) = "11") then
            iFHA = 1
        
        Else
            iFHA = 0
            
        end if
            
        if (Sess0.Screen.getstring(2, 2, 2) = "12") then
            iVA = 1
        
        Else
            iVA = 0
            
        end if 
            
            
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        Sess0.Screen.sendkeys("<Home>TSK1<Enter>")	
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
            
        
        if (Sess0.Screen.getstring(18, 10, 6) = "LGLLIT") then
            if (Sess0.Screen.getstring(18, 02, 4) = "OPEN") then
                iLitigation = 1
            else
                iLitigation = 0
            end if
        else
            iLitigation = 0 
             
        end if
            
        if (Sess0.Screen.getstring(18, 10, 6) = "DOSLIT") then
            if (Sess0.Screen.getstring(18, 02, 4) = "OPEN") then
                iLitigation = 1
            else
                iLitigation = 0
            end if
        else
            iLitigation = 0
            
        end if
            
        if (Sess0.Screen.getstring(18, 10, 6) = "LGLSCU") then
            if (Sess0.Screen.getstring(18, 02, 4) = "OPEN") then
                iLitigation = 1
            else
                iLitigation = 0
            end if
        else
            iLitigation = 0            
            
        end if
        
        sScrnSUB = "ADD1"
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        Sess0.Screen.sendkeys("<Home>MAS1<Enter>")	
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        Sess0.Screen.putstring sScrnSUB , 3 ,5	    
        Sess0.Screen.sendkeys( "<Enter>") 
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
        
        
        if (Sess0.Screen.getstring(17, 61, 1) = "1") then
            iEmployee = 1
        
        Else
            iEmployee = 0
            
        end if
        
        if (Sess0.Screen.getstring(17, 61, 1) = "2") then
            iEmployee = 1
        
        Else
            iEmployee = 0
            
        end if         
        
        if (Sess0.Screen.getstring(17, 61, 1) = "5") then
            iEmployee = 1
        
        Else
            iEmployee = 0
            
        end if
        
        if (Sess0.Screen.getstring(17, 61, 1) = "6") then
            iEmployee = 1
        
        Else
            iEmployee = 0
            
        end if

 
Wasn't sure if I could edit it, but it looks like I can condense it using the case for searches in the same area on the same screen - I'll do that too once I find out how to display results.

Thanks again
 
I'm going to go with this unless you have a better suggestion:

I changed them all to strings and created a new string and will just display the text in a msgbox, because I don't think there is a better way.

Just wanted to post solution in case anyone reads this later.

Code:
        msgtext=" Employee Loan?: " & iEmployee & Chr(10)
        msgtext=msgtext + " Wells Owned?: " & iWellsOwned & Chr(10)
        msgbox msgtext
 


here's several of your if...then...else condensed...
Code:
    If Sess0.Screen.getstring(18, 2, 4) = "OPEN" Then
        Select Case Sess0.Screen.getstring(18, 10, 6)
            Case "LGLLIT", "DOSLIT", "LGLSCU", "6"
                iLitigation = 1
            Case Else
                iLitigation = 0
        End Select
    Else
        iLitigation = 0
    End If
    
    
    Select Case Sess0.Screen.getstring(17, 61, 1)
        Case "1", "2", "5", "6"
            iEmployee = 1
        Case Else
            iEmployee = 0
    End Select
I would also replace these
Code:
        Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
        Sess0.Screen.SendKeys ("<Home>TSK1<Enter>")
        Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
with code like this, which is much more reliable
Code:
        Sess0.Screen.MoveRelative 1, 1
        Sess0.Screen.SendKeys ("<Home>TSK1<Enter>")
         
        Do
            DoEvents
        Loop Until Sess0.Screen.WaitForCursor(r, c)
where r, c is the row and column where you expect the cursor to settle once the mainframe returns data to the emulator.

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
To me it sounds like you want a dialogbox to show your results in a nice way. This is a way to do it.

Code:
Dim variables(11) as string, result(11) as string, yesno(1) as string
Dim iRepurchase as integer, iWellsOwned as integer, iCoLoss as integer, iWOEPBO as integer, iRSI as integer, iREO as integer
Dim iBK as integer, iChargeOff as integer, iFHA as integer, iVA as integer, iLitigation as integer, iEmployee as integer
Declare Function FileDlgFunction(identifier$, action, suppvalue)

Sub Main
    yesno(0) = "NO"
    yesno(1) = "YES"

    variables(0) = "iRepurchase"
    variables(1) = "iWellsOwned"
    variables(2) = "iCoLoss"
    variables(3) = "iWOEPBO"
    variables(4) = "iRSI"
    variables(5) = "iREO"
    variables(6) = "iBK"
    variables(7) = "iChargeOff"
    variables(8) = "iFHA"
    variables(9) = "iVA"
    variables(10) = "iLitigation"
    variables(11) = "iEmployee"

    result(0) = yesno(iRepurchase)
    result(1) = yesno(iWellsOwned)
    result(2) = yesno(iCoLoss)
    result(3) = yesno(iWOEPBO)
    result(4) = yesno(iRSI)
    result(5) = yesno(iREO)
    result(6) = yesno(iBK)
    result(7) = yesno(iChargeOff)
    result(8) = yesno(iFHA)
    result(9) = yesno(iVA)
    result(10) = yesno(iLitigation)
    result(11) = yesno(iEmployee)
    
    Begin Dialog CallDialog 150, 150, 150, 135, "Results", .FileDlgFunction
        ListBox           5,   5,  80, 110, variables, .L1
        ListBox          90,   5,  50, 110, result, .L2
        OkButton         45, 110,  45,  14
    End Dialog

    Dim CallDialog1 as CallDialog
    
    On Error Resume Next

    Dialog CallDialog1
   
End Sub

Function FileDlgFunction(identifier$, action, suppvalue)
    Select Case action
        Case 1
        Case 2
        Case 3
        Case 4
        Case 5
            If DlgFocus() = "L1" Then
                DlgValue("L2"),DlgValue("L1")
            Else
                DlgValue("L1"),DlgValue("L2")
            End If
    End Select
End Function

Hope it helps.
 
Lakare, this looks great. I've since reformatted them into strings - if I can't figure out how to work it in I'll check back. Excellent - exaclty what I wanted!
 
This is working great, but one problem - when lines are highlighted in the box they tend to flicker or "trip out" as if something is wrong... is there anything I can do to stop it?

Otherwise perfect solution.
 
In the function FileDlgFunction, I make the corresponding field marked. When it is action case five for the Dialog, it always happens. So when you move yoru mouse around it can flicker yes, don't know if you can remove that. I believe it won't flicker if you keep your mouse still, but not sure.

I might be able come up with a dirty fix if you really need it.
 
Not really important, I am going to roll out the macro to 100+ coworkers so just want it to look clean. If it is just how it looks and there is nothing adverse happening in the background that is fine.

This worked excellently! Thanks again
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top