![]() |
|
|
| Subject:
Convert VBScript to JScript
Category: Computers > Programming Asked by: schulze-ga List Price: $10.00 |
Posted:
25 Dec 2002 11:46 PST
Expires: 30 Jan 2003 13:57 PST Question ID: 133308 |
I need help converting this to JScript:
<%
Const ksKbaURL = "http://www.kbalertz.com/websvc/latestkbs.aspx?t=%t%&c=%c%"
Const ksKbaCount = 10
Const ksKbaX = "kbAlertz"
Const ksKbaXslPath = "/kbAlertz.xsl"
Const ksKbaError="kbAlertz is unavailable at this time."
Function kbAlertz(iTech)
On Error Resume Next
Dim sRet, lTech, sURL
lTech = 0
If IsNumeric(iTech) Then
lTech = CLng(iTech)
End If
If CLng(lTech) < 1 Then lTech = 1
lTech = Trim(lTech)
sURL = Replace(ksKbaURL, "%t%", lTech)
sURL = Replace(sURL, "%c%", ksKbaCount)
lTech = ksKbaX & "." & lTech
If Application(lTech) & "" <> "" Then
If (Application(lTech & ".Refresh") > Now()) And _
(Application(lTech & ".xsl") = _
Application(ksKbaX & ".xsl.Refresh")) Then
kbAlertz = Application(lTech)
Exit Function
End If
End If
Dim oXml
Set oXml = Server.CreateObject("Msxml2.ServerXMLHTTP")
oXml.Open "GET", sURL , False
oXml.send
Dim oXsl
Set oXsl = Server.CreateObject("Msxml2.DOMDocument")
oXsl.async = False
If Application(ksKbaX & ".xsl") & "" = "" Then
kbAlertzXSL
End If
oXsl.loadXML Application(ksKbaX & ".xsl")
Dim oXmlD
Set oXmlD = Server.CreateObject("Msxml2.DOMDocument")
oXmlD.loadXML oXml.responseText
sRet = oXmlD.transformNode(oXsl)
If Err = 0 Then
kbAlertz = sRet
Application.Lock
Application(lTech) = sRet
Application(lTech & ".Refresh") = NoonTomorrow
Application(lTech & ".xsl") = _
Application(ksKbaX & ".xsl.Refresh")
Application.UnLock
Else
If Application(lTech) & "" <> "" Then
kbAlertz = Application(lTech)
Else
kbAlertz = ksKbaError
End If
Err.Clear
End If
sRet = ""
sURL = ""
Set oXmlD= Nothing
Set oXsl = Nothing
Set oXml = Nothing
End Function
Sub kbAlertzXSL()
Dim oXsl
Set oXsl = Server.CreateObject("Msxml2.DOMDocument")
oXsl.async = False
oXsl.Load Server.MapPath(ksKbaXslPath)
Application.Lock
Application(ksKbaX & ".xsl") = oXsl.xml
Application(ksKbaX & ".xsl.Refresh") = Now()
Application.UnLock
Set oXsl = Nothing
End Sub
Function NoonTomorrow()
Dim dTomorrow
dTomorrow = FormatDateTime(CDate(Now()+1), vbShortDate)
dTomorrow = CDate(dTomorrow) + 0.5
NoonTomorrow = CDate(dTomorrow)
End Function
%> | |
| |
| |
| |
|
|
| There is no answer at this time. |
|
| Subject:
Re: Convert VBScript to JScript
From: itonydev-ga on 10 Jan 2003 01:46 PST |
Do you know javascript and/or vbscript? That is very important for
context. If you know both or have the knack for seeing patterns you
just have to go line by line and convert each statement and pay
attention to the compiler errors. Most languages have the same
constructs except for research projects and theses ;)
Some major differences between vbscript and jscript are:
1) jscript likes ; at the end of each statement
2) jscript likes if(<expr>){} syntax instead of if <expr> <crlf> End
If
3) vbscript allows you to call functions and "subs" without parameters
if you dont care about the return value, jscript requires all function
calls to include the parentheses.
jscript uses the
var varname [= <default];
syntax while vbscript uses
dim varname
varname = <value> 'or set varname = <object>
for 'setting' objects to variables.
4) exit function and exit sub are replaced by return;
5) string manipulation methods are on the string object instead of
global static methods.
6) i dont know conversion functions but if you search for "JavaScript
Converstion Functions" in google you find plenty of reference.
7) error handling is different, you will want to look up "JavaScript
Error Handling" in google as well.
8) If it is a compile error it is probably something that any client
side javascript code you find with error handling will be sufficient
for a reference.
~tony |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
| Search Google Answers for |
| Google Home - Answers FAQ - Terms of Service - Privacy Policy |