Thread Tools Display Modes
07-03-10, 03:08 AM   #1
Ganzo
A Kobold Labourer
Join Date: Jul 2010
Posts: 1
Can it be possible to parse a txt file?

Hi,

I'm new to developing WOW addons, and I'm currently having a diffucilty.
In my addon I want to interface with anther application running in windows, for now the only way I could do that is by reading txt files.

Is it possible to open a txt file for parsing?
I tried the following lua code, but it did not work:

function MyAddon_OnLoad()
local f = assert(io.open("my_file.txt", "r"))
local t = f:read("*all")
f:close()
end

Is it possible to open txt files?
Is my code wrong?

Thanks for helping
  Reply With Quote
07-03-10, 03:53 AM   #2
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
WoW's Lua parser is run in a sandbox - there is no File I/O nor networking ability.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
07-03-10, 03:57 AM   #3
tsadok
An Aku'mai Servant
 
tsadok's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 32
This is not possible because it allows more interactivity with other applications than Blizzard is comfortable with. One thing you could do, before logging in, is save a .lua file to WTF file in the appropriate place, in this format:

MyTextFile = [[
--text file here
]]

and the global MyTextFile will contain the contents of the file (this uses Lua long strings).
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Can it be possible to parse a txt file?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off