Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ File IO, Syntax for network file path access
File IO, Syntax for network file path access
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Sat 02 Dec 2006 09:49 PM (UTC) |
Message
| Using various IO functions, I'd like to access a file stored on a network drive.
Currently, I have a file called (for instance) sw.txt in the default folder MC accesses for logs and so on. This works well, but is only local.
using something like;
***script lines***
for line in io.lines ("sw.txt") do
print (line)
***more script lines***
The file(s) in question may be stored on a server called "aardsp" in a folder called "texthelps", so the path is \\aardsp\texthelps\sw.txt. I've tried a number of combinations but I can't get the IO function to get the file from anywhere other than the local file, ideas very much appreciated.
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Sat 02 Dec 2006 10:53 PM (UTC) |
Message
| Lua's IO probably doesn't support opening network paths.
Try mapping a network drive so that you can get a proper drive-based path. Then Lua will probably be happier with it. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #2 on Sun 03 Dec 2006 12:14 AM (UTC) |
Message
| Sure mapping the drive will help, but I still can't explicitly direct mush to consistently grab a file from any directory other than that currently the default.. even somewhere on local c:\...somewhere.
I should have been clearer in the original question... | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Sun 03 Dec 2006 12:58 AM (UTC) |
Message
| Oh, so you can't get any other path?
Are you properly escaping your backslashes? Something like \t means a literal tab; if you want to say, e.g., c:\tmp you have to write c:\\tmp. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #4 on Sun 03 Dec 2006 01:48 AM (UTC) |
Message
| Assuming a file at C:\text\sw.txt
using io function (first line only here);
for line in io.lines ("C:\\text\\sw.txt") do
gives this error;
[string "Alias: "]:1: bad argument #1 to 'lines' (C: extsw.txt: Invalid argument)
stack traceback:
[C]: in function 'lines'
[string "Alias: "]:1: in main chunk
I'm missing something obvious I'm sure, appreciate your help again. | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #5 on Sun 03 Dec 2006 01:54 AM (UTC) Amended on Sun 03 Dec 2006 02:18 AM (UTC) by David Haley
|
Message
| for line in io.lines("c:\\tmp\\delete_me\\phil-151-defs.txt") do
print(line)
end
That worked for me, but outside of MUSHclient.
You can also try double-escaping, because MUSHclient might be processing one level of escaping. Try \\\\ instead of just \\.
EDIT: added double escaping. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #6 on Sun 03 Dec 2006 02:09 AM (UTC) |
Message
| Note in the previous post, I'd used \\ instead of \.
**stumped for now** | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #7 on Sun 03 Dec 2006 02:18 AM (UTC) |
Message
| Oops. Looks like the forum escaped the slashes for me... I edited my post and fixed it. Please look at it again. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Fletchling
Australia (54 posts) Bio
|
Date
| Reply #8 on Sun 03 Dec 2006 02:25 AM (UTC) |
Message
| Awesome, 4 backslashes works, thanks Ksilyan.
Now snugglepot and cuddlepie can share the same map, quest and speedwalk files, she'll be happy about that.
| Top |
|
Posted by
| Nick Gammon
Australia (23,158 posts) Bio
Forum Administrator |
Date
| Reply #9 on Sun 03 Dec 2006 04:47 AM (UTC) |
Message
| You can save a lot of backslashes by using forward slashes, that seems to work:
for line in io.lines ("c:/tmp/delete_me/foo.txt") do
print(line)
end
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #10 on Sun 03 Dec 2006 05:45 AM (UTC) |
Message
| Yes, indeed, Windows also is happy taking forward slashes. I probably should have mentioned that. :-) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
24,010 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top