|  | 
	
	
		| Private Adept
 
 
 Joined: 10 Jan 2002
 Posts: 264
 Location: USA
 
 | 
			
			  |  Posted: Wed Aug 01, 2012 5:12 pm 
 passing a variable to vbscript #MSS [not-solved]
 
 |  
				| t1 is set to  "8/01/2012 12:10:53" sans quotes t2 is set to "8/01/2012 12:44:35" also without quotes
 
 
 #MSS {MinDiff = DateDiff("n",~"@t1~",~"@t2~")}
 min_uptime = %mss(MinDiff)
 echo ... @min_uptime ... %mss(MinDiff)
 
 ... 0 ... 0
 
 #MSS {MinDiff = DateDiff("n",@t1,@t2)}
 min_uptime = %mss(MinDiff)
 echo ... @min_uptime ... %mss(MinDiff)
 
 ... 0 ... 0
 
 the 1st example returns the correct # of minutes in zmud
 
 also another script... using DSPing.dll as a COM object...
 
 this works as expected in zmud...
 
 
 
 
	  | Code: |  
	  | Set cc = CreateObject( "Zmud.Application") Set ss = cc.CurrentSession
 
 Set Ping = CreateObject( "DSPing.Ping" )
 Result = Ping.DoPing("%1")
 If Result = 0 then
 ss.ProcessCommand("#VAR ping_result " & Result & " ")
 ss.ProcessCommand("#VAR ping_minimum " & Ping.Minimum & " ")
 ss.ProcessCommand("#VAR ping_average " & Ping.Average & " ")
 ss.ProcessCommand("#VAR ping_maximum " & Ping.Maximum & " ")
 '    msgbox("Ping successful to %1." & vbCrLf & "Approximate round trip times in milliseconds:" & vbCrLf & "Minimum = " & Ping.Minimum & "ms" & vbCrLf & "Maximum = " & Ping.Maximum & "ms" & vbCrLf & "Average = " & Ping.Average & "ms")
 Else
 ss.ProcessCommand("#VAR ping_result " & Result & " ")
 '    msgbox("Ping failed.")
 End If
 
 ss.ProcessCommand("ping_results %1 %2")
 
 Set cc = Nothing
 Set ss = Nothing
 Set Result = Nothing
 Set Ping = Nothing
 |  
 the various double quotes don't play well in cmud, changing to ' quotes makes vbscript puke.
 
 output in zmud:
 ping google.com
 Ping to google.com) Min: 15 Avg: 20 Max: 31
 |  | 
	
	  | 
		    
			  | 
 Last edited by Private on Fri Aug 03, 2012 1:12 am; edited 2 times in total
 |   |  | 
	
		|  | 
	
		| Daern Sorcerer
 
 
 Joined: 15 Apr 2011
 Posts: 809
 
 
 | 
			
			  |  Posted: Wed Aug 01, 2012 7:30 pm 
 |  
				| I've never used #MSS, so don't have an answer to your question, but did you know you can use VBScript directly in CMUD now? Just change the language dropdown at the top right in the settings editor. It should list all languages supported by the Windows Scripting Host that you have installed (VBScript comes with Windows of course, so no install required). 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Rahab Wizard
 
 
 Joined: 22 Mar 2007
 Posts: 2320
 
 
 | 
			
			  |  Posted: Wed Aug 01, 2012 8:08 pm 
 |  
				| I see an error in this line: #MSS {MinDiff = DateDiff("n",~"@t1",~"@t2~")}
 
 I assume should be:
 #MSS {MinDiff = DateDiff("n",~"@t1~",~"@t2~")}
 
 But I don't know anything about MSS, so I can't help any further.
 |  | 
	
	  |  | 
	
		|  | 
	
		| Private Adept
 
 
 Joined: 10 Jan 2002
 Posts: 264
 Location: USA
 
 | 
			
			  |  Posted: Wed Aug 01, 2012 11:07 pm 
 |  
				| Daern of course i knew that, you could in zmud as well... you didnt see the second part of my post i assume... 
 Thanks Rahab, guess i typed that too quick, but yea... double quote hell.. whether usin #MSS, %mss, or VBScript through pulldown.
 |  | 
	
	  |  | 
	
		|  | 
	
		| Private Adept
 
 
 Joined: 10 Jan 2002
 Posts: 264
 Location: USA
 
 | 
			
			  |  Posted: Mon Aug 06, 2012 10:17 pm 
 |  
				| Anyone know? running out of time on the cmud trial... gonna stick to zmud if i can't get all my impot issues solved :( 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Rahab Wizard
 
 
 Joined: 22 Mar 2007
 Posts: 2320
 
 
 | 
			
			  |  Posted: Mon Aug 06, 2012 11:57 pm 
 |  
				| If calculating date differences is the only thing stopping you from buying Cmud, you should be aware that people have already written and shared scripts for doing the calculation in Zscript for Cmud.  But if you have other MSS scripts, I don't have anything else to offer. 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Private Adept
 
 
 Joined: 10 Jan 2002
 Posts: 264
 Location: USA
 
 | 
			
			  |  Posted: Tue Aug 07, 2012 4:08 pm 
 |  
				| I have lots of other perl/vbscript scripts... all currently broken on import to cmud 
 |  | 
	
	  |  | 
	
		|  | 
	
		| Daern Sorcerer
 
 
 Joined: 15 Apr 2011
 Posts: 809
 
 
 | 
			
			  |  Posted: Tue Aug 07, 2012 4:31 pm 
 |  
				| Set your t1 and t2 variables to string literal and it works. Looks like autotype is trying to evaluate it, probably because of the slashes. The problem actually had nothing to do with #mss, the contents of your variables were actually evaluating to 0, you can see that easily by #show-ing them on the command line. 
 As for the other code segment, this is probably a stupid question, but did you change Zmud.Application to Cmud.Application? I couldn't actually run your code because I don't have your ping dll, but the double quotes don't look to be a problem to me, they don't break the syntax highlighting anyway...
 |  | 
	
	  |  | 
	
		|  | 
	
		| Private Adept
 
 
 Joined: 10 Jan 2002
 Posts: 264
 Location: USA
 
 | 
			
			  |  Posted: Tue Aug 07, 2012 10:40 pm 
 |  
				| I set the 2 vars to literal as you said, but every time i ran the script, they reset to auto, 
 I was able to get it working by using:
 #CALL %vartype(t1,3)
 #CALL %vartype(t2,3)
 AFTER I changed what was in them with:
 #IF (%ends(%1,1)) {t1 = $month~/%3~/%4%char(32)%5~:%6~:%7}
 
 the previous if resets those vars to auto type, using the #CALL after sets them to literal and with some other tweaks, it now works
 
 
 On the ping script, I might mention that in the script posted above, changing %1 to google.com simply works...
 there is no Cmud.Application... it is still set to Zmud so
 Set cc = CreateObject( "Cmud.Application")
 errors with source not found by the vbscript parser
 
 Leaving: Set cc = CreateObject( "Zmud.Application")
 Changing: Result = Ping. DoPing("google.com")
 ^^^^^^^^^ works... but only if i dont need to enter %1 from the command line which i do.
 
 ping google.com gt
 (Group) Ozzy: 'Ping to  Min: 15 Avg: 15 Max: 16'
 should read
 (Group) Ozzy: 'Ping to  google.com Min: 15 Avg: 15 Max: 16'
 
 google.com is normally in %1 for the script to work with.
 
 p.s. http://dsping-pro.en.softonic.com/  ... put the dll in cmud directory and register it, restart cmud, you know it worked if you get a dsping nag screen as it's a trial. I can't share the paid for version for you to test.
 |  | 
	
	  |  | 
	
		|  | 
	
		| Rahab Wizard
 
 
 Joined: 22 Mar 2007
 Posts: 2320
 
 
 | 
			
			  |  Posted: Tue Aug 07, 2012 11:28 pm 
 |  
				| Perhaps the problem is that you are trying to do implicit concatenation.  Try explicit concatenation: 
 
 
	  | Code: |  
	  | #IF (%ends(%1,1)) {t1 = %concat($month, "/", %3, "/", %4, %char(32), %5, ":", %6, ":", %7)} |  |  | 
	
	  |  | 
	
		|  | 
	
		| Daern Sorcerer
 
 
 Joined: 15 Apr 2011
 Posts: 809
 
 
 | 
			
			  |  Posted: Wed Aug 08, 2012 3:21 am 
 |  
				| There is definitely a Cmud.Application. I just tested with this: 
 
 
	  | Code: |  
	  | Set cc = CreateObject("Cmud.Application") Set ss = cc.CurrentSession
 ss.ProcessCommand("#SHOW test")
 Set ss = Nothing
 Set cc = Nothing
 |  and it works just fine. Zmud.Application seems to work too though, so I guess there's no harm in using it.
 
 Moving on... it looks like the problem is with your use of %1 in quotes. In zMUD, parameters were substituted in before the code was run. If you did something like Ping.DoPing("%1"), the %1 got filled in right away and the VBScript interpreter only ever saw Ping.DoPing("google.com"). That pre-substitution doesn't happen in CMUD anymore, so the VBScript interpreter never sees google.com. Unfortunately, I can't find a good solution for this. The best I can come up with is to use a zScript alias, store %1 in a variable and call a VBScript function (or use #MSS), referencing your variable with zvar.varname. A simple example:
 
 
 
	  | Code: |  
	  | testvar = %1 #MSS {msgbox(zvar.testvar)}
 |  |  | 
	
	  |  | 
	
		|  | 
	
		|  | 
	
		|  |