Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


recursive function

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,3488
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> recursive function
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 recursive function - 6/22/2005 6:55:56 AM   
  GregSD

 

Posts: 3
Score: 0
Joined: 6/22/2005
From:
Status: offline
Trying to call a function again if a value for ValidData is not entered. When I press Enter without entering any data, the function simply quits. Any ideas? Thanks.


strNewProfPath = ValidData
Function ValidData
WScript.StdOut.WriteLine "Enter new profile server and share: "
ValidData = WScript.StdIn.ReadLine
If ValidData = "" Then
WScript.Echo "User profile cannot be set to nothing."
WScript.Echo
strNewProfPath = ValidData
End If
WScript.Echo
End Function
 
 
Post #: 1
 
 Re: recursive function - 6/22/2005 7:19:20 AM   
  royb5000

 

Posts: 54
Score: 0
Joined: 5/4/2005
From: USA
Status: offline
Try this out. I think your problem was that you have to give a value of some type to the string or you get a value of null which vbscript can't handle. So you just give it a value of one space and it works. Also, you just had to call the function again, you didn't have to reset the value of strnewProfPath because you had not finished running ValidData yet. Hope this helps.


strNewProfPath = ValidData
Function ValidData
WScript.StdOut.WriteLine "Enter new profile server and share: "
ValidData = WScript.StdIn.ReadLine & " "
If ValidData = " " Then
WScript.Echo "User profile cannot be set to nothing."
WScript.Echo
ValidData
End If
WScript.Echo
End Function

(in reply to GregSD)
 
 
Post #: 2
 
 Re: recursive function - 6/22/2005 8:28:37 AM   
  ehvbs

 

Posts: 2220
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
In function ValidData() the Name "ValidData" means the variable used
to specify the return value of the function. If you just press enter
after the prompt, this variable is set to "".

      
means

      
To call the Function, use

      
but consider, that ValidData is still "" after the second call of
ValidData(). I would start from something like this:

      

(in reply to GregSD)
 
 
Post #: 3
 
 Re: recursive function - 6/22/2005 8:39:05 AM   
  GregSD

 

Posts: 3
Score: 0
Joined: 6/22/2005
From:
Status: offline
royb5000,

Setting the quotes as you mentioned, produced the same effect.

Within the function, I then tried removing strNewProfPath = and left ValidData. That seemed to help but... Say I hit the enter key ten times and then enter a server name and path. The recursion works, but when I finally enter valid data, all the previous blank entries are echoed to the screen and the valid data doesn't appear to get assigned to strNewProfPath.

(in reply to GregSD)
 
 
Post #: 4
 
 Re: recursive function - 6/22/2005 9:08:52 AM   
  GregSD

 

Posts: 3
Score: 0
Joined: 6/22/2005
From:
Status: offline
ehvbs,

That code appears to work as I need.

Thanks to all for the input.

Greg

(in reply to GregSD)
 
 
Post #: 5
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> recursive function Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts