Dialog error

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
HPROS
Junior Coder
Posts: 35
Joined: Tue Sep 16, 2003 7:52 pm
Location: Columbia, CT
Contact:

Dialog error

Post by HPROS » Tue Nov 30, 2004 5:14 am

I am using a couple of dialogs in my script, and the primary one is used as a main menu. After an option is selected & executed from the main menu, then I come back to the menu by using the "show" command to redisplay the dialog (menu).

I have used this successfully in the past, and am stumped with the following error that I am getting:

"A component named display already existis"

"display" is the name of my dialog.

The first time through everything is fine, it is when I go back to the show command and make a selection that I get my error. It hangs up so bad that I have to "quit" Macro Scheduler altogether.

Here is part of the code:

Dialog>display
Caption=WCCU Loan Payoff Calculator
Left=300
Top=300
Width=290
Height=350
Label=Please enter the following information to calculate a ,5,5
Label=payoff on 30 - 360 mortgages:,5,25

Label= ***** PLEASE TAB BETWEEN FIELDS *****,5,45
Label=Loan Balance:,5,85
Edit=bal,5,102,230,Enter as xxxxxx.xx
Label=Interest Rate:,5,125
Edit=rate,5,142,100,Enter 7.5 as .075
Label=Unpaid Interest:,5,165
Edit=unpaid,5,182,230,Enter any unpaid interest as xxxxxx.xx
Label=Number of days till payoff:,5,205
Edit=days,5,222,50,# Days
Button=Continue,5,265,50,20,1
Button=Exit Macro,100,265,100,20,2
EndDialog>display


Label>MainLoop

Show>display,result

If>result=2,End
if>display.bal=Enter as xxxxxx.xx,err1
if>display.rate=Enter 7.5 as .075,err2
if>display.unpaid=Enter any unpaid interest as xxxxxx.xx,err3
if>display.days=# Days,err4


Is there something I need to be clearing out of memory at each pass?

BTW I am on the latest release 7.3.03 but it happened on 7.2 also so I don't think it is release related. My OS is WinXPPro.

Thank you in advance for your help.

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Nov 30, 2004 8:39 am

Do you have another macro running with a dialog also called Display? If so, use a different name - rename one of them. Without seeing your full script I can't offer any more suggestions.
MJT Net Support
[email protected]

HPROS
Junior Coder
Posts: 35
Joined: Tue Sep 16, 2003 7:52 pm
Location: Columbia, CT
Contact:

Post by HPROS » Tue Nov 30, 2004 10:50 am

No, one Dialog is called Display and the other is Display1.

My previous success with using dialog was with buttons only, not with buttons, edit fields and chekboxes like I am using now, I wonder if I am doing something wrong there.

Thank you for the suggestion.
Last edited by HPROS on Tue Nov 30, 2004 12:13 pm, edited 1 time in total.

HPROS
Junior Coder
Posts: 35
Joined: Tue Sep 16, 2003 7:52 pm
Location: Columbia, CT
Contact:

Post by HPROS » Tue Nov 30, 2004 10:52 am

Do you want me to e-mail my script, or post it here? It is ~200 lines.

HPROS
Junior Coder
Posts: 35
Joined: Tue Sep 16, 2003 7:52 pm
Location: Columbia, CT
Contact:

Code

Post by HPROS » Tue Nov 30, 2004 12:13 pm

So you don't have to fly blind, here is the code... run it and just enter "1" throughout the first menu and then select continue. On the results window, just select continue, and that will return you to the main dialog for another calculation, so now enter "2" and follow previous steps. This will get the error I explained. - Thanks


///MUST GET SMTP FROM CLIENT///
//let>smtp=smtp.charter.net
input>smtp,Please enter your smtp host....
//let>flag=0


Dialog>display
Caption=WCCU Loan Payoff Calculator
Left=300
Top=300
Width=290
Height=350
Label=Please enter the following information to calculate a ,5,5
Label=payoff on 30 - 360 mortgages:,5,25

Label= ***** PLEASE TAB BETWEEN FIELDS *****,5,45
Label=Loan Balance:,5,85
Edit=bal,5,102,230,Enter as xxxxxx.xx
Label=Interest Rate:,5,125
Edit=rate,5,142,100,Enter 7.5 as .075
Label=Unpaid Interest:,5,165
Edit=unpaid,5,182,230,Enter any unpaid interest as xxxxxx.xx
Label=Number of days till payoff:,5,205
Edit=days,5,222,50,# Days
Button=Continue,5,265,50,20,1
Button=Exit Macro,100,265,100,20,2
EndDialog>display


Label>MainLoop

Show>display,result

If>result=2,End
if>display.bal=Enter as xxxxxx.xx,err1
if>display.rate=Enter 7.5 as .075,err2
if>display.unpaid=Enter any unpaid interest as xxxxxx.xx,err3
if>display.days=# Days,err4
//if>flag=0,first,

//label>first
//let>flag=1
let>r=display.rate
let>b=display.bal
let>u=display.unpaid
let>d=display.days

let>p1=r/365
let>p2=u+b
let>p3=p1*b
let>p4=p3*d
let>payoff=p4+p2

//LET>payoff={%r%/365*%b%*%d%+%u%+%b%}

//Round Off up if 5 in 1000th place is 5 or better//

Position>.,payoff,1,StartPos
let>StartPos=StartPos+2
let>cknext=StartPos+1
MidStr>payoff,cknext,1,rnd1
If>rnd1>4,add1,noadd
label>add1
let>payoff=payoff+.01
label>noadd
MidStr>payoff,1,StartPos,payoff1

//Check result

If>result=1,DisplayM

IfFileExists>c:\payoff.txt,del,cont
label>del
del>c:\payoff.txt
label>cont

GetDate>date
WriteLn>c:\payoff.txt,result,%date% - WCCU
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Principal Balance was: %b%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Interest Rate: %r%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Unpaid Interest Amount was: %u%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Number of Days was: %d%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Payoff is: %payoff1%

if>display1.email=True,mail
wait>1
if>display1.print=True,print
wait>1
If>result1=1,MainLoop
If>result1=2,End

Goto>MainLoop

SRT>mail

let>fromemail=[email protected]
let>toemail=%display1.emaila%
let>subject="WCCU - Payoff Estimate
let>msg="Attached is the payoff that you requested:"
let>attach=c:\payoff.txt
Label>continue
SMTPSendMail>toemail,smtp,fromemail,fromemail,subject,msg,attach
Pos>250,SMTP_RESULT,1,pres
If>pres>0,success,nosuccess
Label>success
MessageModal>Your Message Was Sent Successfully
Goto>end
Label>nosuccess
MessageModal>The following error occured: %SMTP_RESULT%
Label>end
End>mail


srt>print

VBSTART

Sub Printtxt(txtFile)
Dim wrd 'As Word.Application
Dim doc 'As Word.Document
Set wrd = CreateObject("Word.Application")
wrd.application.Visible = False
'Set the printer here
'wrd.ActivePrinter = "HP officeJet 5500 series"
'wrd.ActivePrinter = "default"
Set doc = wrd.Documents.Open(txtFile)
doc.PrintOut
doc.Close
wrd.Quit
Set wrd = Nothing
End Sub

VBEND

VBRun>Printtxt,C:\payoff.txt


End>print

SRT>DisplayM

///Display the results of the payoff with Print and e-mail options///

Dialog>display1
Caption=WCCU Loan Payoff - Results
Left=300
Top=300
Width=225
Height=275

Label=The Principal Balance was: %b%,5,15
Label=The Interest Rate: %r%,5,35
Label=The Unpaid Interest Amount was: %u%,5,55
Label=The Number of Days was: %d%,5,75
Label=The Payoff is: %payoff1%,5,95
CheckBox=email,E-mail?,5,135,90,False
Edit=emaila,5,155,175,Enter e-mail Address
CheckBox=print,Print?,80,135,90,False

Button=Continue,5,195,50,20,1
Button=Exit Macro,80,195,100,20,2

EndDialog>display1

Show>display1,result1

End>DisplayM



/////ERROR ROUTINES/////

srt>err1
Messagemodal>>>>>>>>>>>>>>> ERROR 1 MainLoop
End>err1
srt>err2
Messagemodal>>>>>>>>>>>>>>> ERROR 2 MainLoop
End>err2
srt>err3
Messagemodal>>>>>>>>>>>>>>> ERROR 3 MainLoop
End>err3
srt>err4
Messagemodal>>>>>>>>>>>>>>> ERROR 4 MainLoop
End>err4
srt>err5
Messagemodal>>>>>>>>>>>>>>> ERROR 5 MainLoop
End>err5

label>End

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Nov 30, 2004 6:25 pm

No wonder! You are trying to create Display1 in each loop, so second time round it errors out. Move the Display1 block to the top of the script before the loop label.

Dialog blocks CREATE dialogs. Show commands SHOW them. You can only create something once.

So here's the fixed version of your script:


///MUST GET SMTP FROM CLIENT///
//let>smtp=smtp.charter.net
input>smtp,Please enter your smtp host....
//let>flag=0


Dialog>display
Caption=WCCU Loan Payoff Calculator
Left=300
Top=300
Width=290
Height=350
Label=Please enter the following information to calculate a ,5,5
Label=payoff on 30 - 360 mortgages:,5,25

Label= ***** PLEASE TAB BETWEEN FIELDS *****,5,45
Label=Loan Balance:,5,85
Edit=bal,5,102,230,Enter as xxxxxx.xx
Label=Interest Rate:,5,125
Edit=rate,5,142,100,Enter 7.5 as .075
Label=Unpaid Interest:,5,165
Edit=unpaid,5,182,230,Enter any unpaid interest as xxxxxx.xx
Label=Number of days till payoff:,5,205
Edit=days,5,222,50,# Days
Button=Continue,5,265,50,20,1
Button=Exit Macro,100,265,100,20,2
EndDialog>display

Dialog>display1
Caption=WCCU Loan Payoff - Results
Left=300
Top=300
Width=225
Height=275

Label=The Principal Balance was: %b%,5,15
Label=The Interest Rate: %r%,5,35
Label=The Unpaid Interest Amount was: %u%,5,55
Label=The Number of Days was: %d%,5,75
Label=The Payoff is: %payoff1%,5,95
CheckBox=email,E-mail?,5,135,90,False
Edit=emaila,5,155,175,Enter e-mail Address
CheckBox=print,Print?,80,135,90,False

Button=Continue,5,195,50,20,1
Button=Exit Macro,80,195,100,20,2

EndDialog>display1

Label>MainLoop

Show>display,result

If>result=2,End
if>display.bal=Enter as xxxxxx.xx,err1
if>display.rate=Enter 7.5 as .075,err2
if>display.unpaid=Enter any unpaid interest as xxxxxx.xx,err3
if>display.days=# Days,err4
//if>flag=0,first,

//label>first
//let>flag=1
let>r=display.rate
let>b=display.bal
let>u=display.unpaid
let>d=display.days

let>p1=r/365
let>p2=u+b
let>p3=p1*b
let>p4=p3*d
let>payoff=p4+p2

//LET>payoff={%r%/365*%b%*%d%+%u%+%b%}

//Round Off up if 5 in 1000th place is 5 or better//

Position>.,payoff,1,StartPos
let>StartPos=StartPos+2
let>cknext=StartPos+1
MidStr>payoff,cknext,1,rnd1
If>rnd1>4,add1,noadd
label>add1
let>payoff=payoff+.01
label>noadd
MidStr>payoff,1,StartPos,payoff1

//Check result

If>result=1,DisplayM

IfFileExists>c:\payoff.txt,del,cont
label>del
del>c:\payoff.txt
label>cont

GetDate>date
WriteLn>c:\payoff.txt,result,%date% - WCCU
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Principal Balance was: %b%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Interest Rate: %r%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Unpaid Interest Amount was: %u%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Number of Days was: %d%
WriteLn>c:\payoff.txt,result,
WriteLn>c:\payoff.txt,result,The Payoff is: %payoff1%

if>display1.email=True,mail
wait>1
if>display1.print=True,print
wait>1
If>result1=1,MainLoop
If>result1=2,End

Goto>MainLoop

SRT>mail

let>fromemail=[email protected]
let>toemail=%display1.emaila%
let>subject="WCCU - Payoff Estimate
let>msg="Attached is the payoff that you requested:"
let>attach=c:\payoff.txt
Label>continue
SMTPSendMail>toemail,smtp,fromemail,fromemail,subject,msg,attach
Pos>250,SMTP_RESULT,1,pres
If>pres>0,success,nosuccess
Label>success
MessageModal>Your Message Was Sent Successfully
Goto>end
Label>nosuccess
MessageModal>The following error occured: %SMTP_RESULT%
Label>end
End>mail


srt>print

VBSTART

Sub Printtxt(txtFile)
Dim wrd 'As Word.Application
Dim doc 'As Word.Document
Set wrd = CreateObject("Word.Application")
wrd.application.Visible = False
'Set the printer here
'wrd.ActivePrinter = "HP officeJet 5500 series"
'wrd.ActivePrinter = "default"
Set doc = wrd.Documents.Open(txtFile)
doc.PrintOut
doc.Close
wrd.Quit
Set wrd = Nothing
End Sub

VBEND

VBRun>Printtxt,C:\payoff.txt


End>print

SRT>DisplayM

///Display the results of the payoff with Print and e-mail options///

Show>display1,result1

End>DisplayM



/////ERROR ROUTINES/////

srt>err1
Messagemodal>>>>>>>>>>>>>>> ERROR 1 MainLoop
End>err1
srt>err2
Messagemodal>>>>>>>>>>>>>>> ERROR 2 MainLoop
End>err2
srt>err3
Messagemodal>>>>>>>>>>>>>>> ERROR 3 MainLoop
End>err3
srt>err4
Messagemodal>>>>>>>>>>>>>>> ERROR 4 MainLoop
End>err4
srt>err5
Messagemodal>>>>>>>>>>>>>>> ERROR 5 MainLoop
End>err5

label>End
MJT Net Support
[email protected]

HPROS
Junior Coder
Posts: 35
Joined: Tue Sep 16, 2003 7:52 pm
Location: Columbia, CT
Contact:

Post by HPROS » Tue Nov 30, 2004 10:20 pm

Thank you! I had the first dialog out of the loop for that reason, and then added the second one to display results based on info from the first. Then I kept looking at it and trying different things ughh...

Thank you again for all of your help, you guys are great.

PS Any way to automatically reset the cursor to the top edit box when the Dialog "shows"? Right now when the "show" command is executed it comes back on the "continue" button where it was last set.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Nov 30, 2004 11:00 pm

Untested thought......

Can you grap the Mouse Position as soon as you leave the Dialog, and do a
MouseMove to that position before the Dialog opens again?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts