Re: recursion help request

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"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


.



Relevant Pages

  • Re: recursion help request
    ... corresponding sub-routines, and then return to the inputbox. ... I have tried loops and ended up ... the mainmenu() call at the end of each sub-routine for option 1thru4 to no ...
    (microsoft.public.scripting.vbscript)
  • Re: Problem with a script
    ... I don't mean to offend you or discourage you from working with PHP, ... Reworking your huge script into something concise, ... that I have no understanding of loops is completely asinine. ... throw that in while I am on the subject of programming. ...
    (comp.lang.php)
  • Re: Problem with a script
    ... that I have no understanding of loops is completely asinine. ... loops throughout the script. ... business with a history of hiring low knowledge employees, ... throw that in while I am on the subject of programming. ...
    (comp.lang.php)
  • Re: Help Needed understanding the Problem
    ... Here is rough example of how to set the SourceObjectName in script, showing ... That doesn't use a dynamic properties task, but sets the source via an>> ActiveX script. ... >>> I have a simple DTS that loops through files in a directory and imports>>> them into a table. ... >>> Loops through and gets the firat filename, and assigns it to a global ...
    (microsoft.public.sqlserver.dts)
  • Re: Performance improvement possible? - update
    ... Philip Rhoades wrote: ... The change to a single Ruby script simplified the previous setup ... the multiple loops in stats06 have been collapsed ...
    (comp.lang.ruby)