VB port.
'Created on Apr 12, 2005 by iago
'Ported to VBS Apr 13, 2005 by JoeTheOdd
'Get the list of definitions for the word
Function Define(Word as String) as String
Dim Ret as String, Text as String, Stop as Boolean, Def as String
Word = Replace(Word, " ", "+")
Text = GetPage(Word)
Stop = False
Dim ddIndex as Integer, liIndex as Integer
While Stop = False
ddIndex = InStr(1, Text, "<DD>" 'int ddIndex = text.indexOf("<DD>");
liIndex = InStr(1, Text, "<LI>" 'int liIndex = text.indexOf("<LI>");
If liIndex >= 0 And (ddIndex >= 0 Or liIndex < ddIndex) 'if(liIndex >= 0 && (ddIndex >= 0 ? liIndex < ddIndex : true))
Text = Mid(Text, liIndex + 4) 'text = text.substring(liIndex + 4);
'Not sure how to port this. Someone wanna look into it? --> String def = text.replaceAll("<\\/LI>.*", "");
def = text 'Temporary implementation until correct one is made.
'Not sure how to port this. Someone wanna look into it? --> ret.add(def.replaceAll("<.*?>", "").trim());
ret = ret & def 'Temporary implementation until correct one is made.
Ret = Ret & Mid(Text, InStr(1, Text, "</LI>") + 5)
ElseIf ddIndex > 0 And liIndex >= 0 Or ddIndex < liIndex 'else if(ddIndex >= 0 && (liIndex >= 0 ? ddIndex < liIndex : true))
Text = Mid(Text, InStr(1, Text, ddIndex + 4) 'text = text.substring(ddIndex + 4);
'Not sure how to port this. Someone wanna look into it? --> ef = text.replaceAll("<\\/DD>.*", "");
ef = text 'Temporary implmentation until correct one is made.
'Not sure how to port this. Someone wanna look into it? --> ret.add(def.replaceAll("<.*?>", "").trim());
ret = ret & def 'Temporary implementation until correct one is made.
Text = Mid(Text, InStr(1, Text, "</DD>") + 5) 'text = text.substring(text.indexOf("</DD>") + 5);
Else
Stop = True
End If
Wend
Define = Ret 'return (String []) ret.toArray(new String[ret.size()]);
End Function
Function GetPage(Word as String)
GetPage = scInet.OpenURL("http://dictionary.com/search?q=" & word)
End Function