Sorry that the code is not commented. I intended this for personal use but I thought I would share. I have tried many words and have found only one bug, you cannot use the word "mean" or "meaning" or any word that contains it - Meaningful - Misdemeanor. You will need the Matrix1 Utility Plug-in for this to work.
load dll "urlmon",1
do
if file exist("data.txt")=1 then delete file "data.txt"
input "Type a word to define: ", word$
url$="http://www.google.com/dictionary/json?callback=a&sl=en&tl=en&q=" + word$
file$="data.txt"
DownloadToFile=CALL DLL(1,"URLDownloadToFileA",0,url$,file$,0,0)
do
if file exist("data.txt")=1 then exit
loop
open datafile to read 1, "data.txt"
find$ = datafile string$(1)
a=find sub string$(find$,"meaning")
SET DATAFILE POSITION 1, a+40
find$ = datafile string$(1)
b$=first token$(find$,chr$(34))
b$ = Replace All$( b$, "\x27", "'")
b$ = Replace All$( b$, "–", "-")
b$ = Remove All$(b$,"x3cem")
b$ = Remove All$(b$,"x3e")
b$ = Remove All$(b$,"em\")
b$ = Remove All$(b$,"x3c")
b$ = Remove All$(b$,"\")
b$ = Remove All$(b$,"/")
b$ = Remove All$(b$,"iderogatoryi. ")
b$ = Remove All$(b$,"ioffensivei. ")
b$ = Remove All$(b$,"ivulgari. ")
if b$ = ""
print "" : print "Word not found." : print "" : print "Press any key"
wait key : cls : close datafile 1 : delete dll 1
else
b$=b$+(".")
TextWrapInit() : TextWrapClear() : TextWrap(75, b$)
print ""
for t=1 to array count(TextWrapOutput(0))
print TextWrapOutput(t)
next t
print "" : print "Press any key to restart"
wait key : cls
close datafile 1
endif
loop
TextWrapEnd() : delete dll 1 : end
//I did not write the text wrap functions. They are from Broken_Code at http://forum.thegamecreators.com/?m=forum_view&t=190906&b=1
//===FUNCTIONS===
//This function initates the text wrapper
Function TextWrapInit()
Global Dim TextWrapOutput(1) as string
EndFunction
//This function wraps the text to a given width and handles formatting
Function TextWrap(TextWidth as integer, TextString as string)
Local EndOfLastString as integer =0
Local ArrayLength as integer =1
Local temp$ as string =""
//Clear the TextWrapOutput() array from last time it was used
TextWrapClear()
//Cycle through each character in the string
for t=1 to len(TextString)
//If the length of the next line-string is greater than TextWidth
if len(left$(TextString,t))-EndOfLastString>TextWidth
//Search back until a space is found
for c=t to 1 step -1
//Space found
if mid$(TextString,c)=" "
//Add each character from the end of the last line-string to the space
for s=EndOfLastString+1 to c-1
TextWrapOutput(ArrayLength)=TextWrapOutput(ArrayLength)+mid$(TextString,s)
next s
//Set the end of the last line-string
EndOfLastString=c
//Increment the length of the array
inc ArrayLength,1
//Redim the array
dim TextWrapOutput(ArrayLength)
//Exit the for-loop
c=-1
endif
next c
else
//Text formatting found
if mid$(TextString,t)="["
//Read foward until the next square bracket is found
for c=t to len(TextString)
if mid$(TextString,c)="]"
//Reset the temp$ variable
temp$=""
//Grab all text inbetween
for s=t+1 to c-1
temp$ = temp$+mid$(TextString,s)
next s
//Analyze formatting
select temp$
case "CR" //Carrige return
//Save line string until that point
for s=EndOfLastString+1 to t-1
TextWrapOutput(ArrayLength)=TextWrapOutput(ArrayLength)+mid$(TextString,s)
next s
//Increment the length of the array
inc ArrayLength,1
//Redim the array
dim TextWrapOutput(ArrayLength)
//Continue from other side of formatting
t=EndOfLastString
//New end of string position
EndOfLastString=c+1
endcase
// REMSTART
// Other cases can be added here for other kinds
// of formatting and for adding text from variables
// to the text; here's an example:
// REMEND
case "V1" //Value of variable 1 in place of the original "[V1]"
//Replace text with variable value
TextString=left$(TextString,t-1)+str$(Variable01)+right$(TextString,len(TextString)-(c+1))
endcase
// REMSTART
// With this case you can only use global variables,
// otherwise they will be printed as zero. This formatting
// system also has many other applications besdies variables
// such as tabbing and pretty much anything you can think of.
// REMEND
endselect
//Exit for-loop
c=len(TextString)+1
endif
next c
endif
endif
next t
//Add end of text-string to print que manually because it will be shorter than TextWidth and so will not be caught by the if function.
if len(TextString)>EndOfLastString
for s=EndOfLastString+1 to len(TextString)
TextWrapOutput(ArrayLength)=TextWrapOutput(ArrayLength)+mid$(TextString,s)
next s
endif
EndFunction
//This function clears the TextWrapOutput variable ready for use
Function TextWrapClear()
Global Dim TextWrapOutput(1) as string
TextWrapOutput(1)=""
EndFunction
//This function releases resources used by the text wrapper
Function TextWrapEnd()
UnDim TextWrapOutput(1)
EndFunction