Search and Retrieve

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
earl
Posts: 3
Joined: Sun Jul 08, 2007 7:52 pm

Search and Retrieve

Post by earl » Mon Jul 09, 2007 1:43 pm

I am a newbie to Revolution so I'm not sure if this is doable or has already been done. But here's my question anyway. The project I am working on is to create a dictionary with words and definitions. In trying to collect this information, is it possible to have a script in Revolution Studio that does a search on a selected website and find the revelant text and retrieve it in a file format. For example. I would do a search in a selected site (say google) for the word "abundance". Once the definition for the word was found, it would retrieve the text and save it in a flie to be accessed and/or exported to another document later. If not doable, any workaround suggestions?

Thanks,
Earl

xApple
Posts: 113
Joined: Wed Nov 29, 2006 10:21 pm
Location: Geneva

Post by xApple » Mon Jul 09, 2007 4:23 pm

That's doable.
To get web pages just use commands similar to:

Code: Select all

put url "http://www.google.com/search?q=abundance" into myWebPage
And to write to a file the following is of use:

Code: Select all

on writeFile
  answer folder "Please choose a folder for" && the short name of this stack && "to write in."
  put it into theOutputFolder
  put theOutputFolder & "/" & "dataFile.xls" into myPath
  set the filetype to "XCELTEXT"
  open file myPath for text write
  if the result is not empty then answer "Error !" & return & the result & return & "while opening." with "Damit"
  write myData to file myPath
  if the result is not empty then answer "Error !" & return & the result & return & "while writing." with "Damit"
  close file myPath
end writeFile

on readFile
  global myData
  --
  answer file "A tab-sperated text file is expected"
  put it into theFilePath
  open file theFilePath for text read
  if the result is not empty then answer "Error"
  read from file theFilePath until EOF
  if the result is not "eof" then answer "Error"
  put it into myData
  close file theFilePath
end readFile

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Location: London, UK
Contact:

Post by Mark Smith » Mon Jul 09, 2007 9:40 pm

Also, you can read and write files using the URL form:

put tText into URL "file:someFolder/someFile.txt"

put URL "file:"someFolder/someText.txt" into tText

Best

Marl

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”