Re: recursion help request
- From: "Pegasus [MVP]" <news@xxxxxxxxxxxxx>
- Date: Thu, 30 Apr 2009 23:14:53 +0200
"Vgolfmaster" <Vgolfmaster@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:811E3A53-97D6-4C04-AD36-F3C6D1FDC10C@xxxxxxxxxxxxxxxx
hi,
I have a vbscript that I can not get to recurs properly. If the user
enters
'5' for input, the script should end. For ALL other input: invalid data
returns to the inputbox (this works), and valid data should execute the
corresponding sub-routines, and then return to the inputbox. I am unable
to
format this so far to get it to do this. I have tried loops and ended up
with
mostly endless loops. I have also tried to call (a 2nd call) the
sub-procedure for the main menu (mainmenu()) at the end of the script, but
it
simply stops after the previous sub-routines finish. I have also tried to
add
the mainmenu() call at the end of each sub-routine for option 1thru4 to no
avail, it still stops after each sub-routine.
The inputbox and the use of subroutines for the selections 1-4 are
required,
so I can not re-write this entire thing. Any suggestions?
the script:
Your specification does not require a recursion - it requires a loop. Since
you expect a defined set of input response from the user, the program cries
out for a "Case Select" construct rather than a nested if-then-elseif set of
statements. Here is the main part of your program again. Please note that I
did not review or test the remainder of the code.
'*************************
'Main Processing Section *
'*************************
mainmenu()
Do
Select Case choice
Case 1
program = "PowerPoint"
Logfile()
Powerpoint()
Case 2
program = "Excel"
Logfile()
Excel()
Case 3
Viewlogfile()
Case 4
Deletelogfile()
Case Else
WScript.quit
End Select
Loop
'********************************************
'Main Menu for player input and value testing
'********************************************
Sub mainmenu()
Do
choice = (InputBox(_
("1. Run PowerPoint") & VbCrLf & _
("2. Run Excel") & VbCrLf & _
("3. View Log File") & VbCrLf &_
("4. Delete Log File") & VbCrLf & _
("5. Quit") & VbCrLf & VbCrLf & vbTab & vbTab & vbTab & _
"Choose By Number",title))
if IsNumeric(choice) then if (choice > 0) and (choice < 6) then Exit Do
MsgBox("Your selection was not valid")
Loop
End Sub
.
- Follow-Ups:
- Re: recursion help request
- From: Vgolfmaster
- Re: recursion help request
- References:
- recursion help request
- From: Vgolfmaster
- recursion help request
- Prev by Date: Re: recursion help request
- Next by Date: Close a Page and Return to Desk Top
- Previous by thread: Re: recursion help request
- Next by thread: Re: recursion help request
- Index(es):
Relevant Pages
|