Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jun 27, 2009 2:05 am   

Creating and Launching Text Files
 
I can't figure out how to create a file and then later launch in Notepad for example. It always says it cannot find the file even though it creates it in the session folder. Even if I use a relative path name it can't find it. If it creates it in the session folder automatically, shouldn't that be the first place it looks when trying to open it? What if you use the package on different computers? You don't want to give a specific file path that may not exist so how exactly do you open the file after you create it? Simply referring to "filename.txt" will not work.

This (..\..\My Games\CMUD\filename.txt) worked originally until I loaded the package into a session and then it creates the file in the session folder so that no longer works.

Sorry if I am asking a dumb question again.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jun 27, 2009 9:34 am   
 
Anyone have an answer to this? I'd really like to figure it out.

I tried using (..\..\My Games\CMUD\%title\filename.txt) and that didn't work either.
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sat Jun 27, 2009 3:38 pm   
 
I've tried the following commands form the command line and they work as described in the help:

#LAUNCH "notepad.exe bugreport.txt" - opens the "bugreport.txt" file in the CMUD folder
#LAUNCH "notepad.exe packages\somefile.txt" - opens the "somefile.txt" from the CMUD\packages folder

Edit: I'm under XP
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sat Jun 27, 2009 8:52 pm   
 
As I have said already, that does NOT work.


I did the following to create the file:

Code:
#file 2 "testfile.txt"
#write 2 {Welcome !}
#write 2 {----------------------------------------------}
#write 2 {This is a test.}
#close 2


It showed this in the output:

Opened testfile.txt as file 2
Closed C:\Documents and Settings\XXXX\My Documents\My Games\CMUD\testfile.txt on file 2

Then I did the following to launch the file:

Code:
#launch {"notepad.exe testfile.txt"}

Code:
#launch "notepad.exe testfile.txt"


Neither works. It says "Cannot find the testfile.txt file. Do you want to create a new file?" when it launches Notepad. I'm under Windows XP Pro.

If I do:
Code:
#launch "notepad.exe" "packages\testfile.txt"


It just opens an empty text file in Notepad titled untitled and not the testfile.txt, which does exist because I just went to the director it showed it saved it to and it is there and has the text writing in it. All that does is just open notepad period.

If I do:
Code:
#launch {"notepad.exe" "CMUD\testfile.txt"}


or

Code:
#launch {"notepad.exe CMUD\testfile.txt"}


or

Code:
#launch {"notepad.exe" %char(34)CMUD\testfile.txt%char(34)}


It says the system cannot find the path specified...

So then I tried:

Code:
#launch {"notepad.exe" %char(34)..\..\..\CMUD\testfile.txt%char(34)}


Which did work and opens the file. The only damn problem is it isn't going to save it in the same folder all the time. If you load the package in a session it goes to that particular session folder, which adds another folder deep.

I moved the file to CMUD\Packages\testfile.txt in the My Games folder and did:

Code:
#launch {"notepad.exe" %char(34)Packages\testfile.txt%char(34)}


and

Code:
#launch {"notepad.exe" %char(34)..\..\..\..\Packages\testfile.txt%char(34)}


Now suddenly it can't find the file again.

So I tried the absolute path.

Code:
#launch {"notepad.exe" %char(34)C:\Documents and Settings\XXXX\My Documents\My Games\CMUD\Packages\testfile.txt%char(34)}


It then opens it.

However, the failure here is that the following refers to the same thing and it cannot find the file.

Code:
#launch {"notepad.exe" %char(34)..\..\..\..\CMUD\Packages\testfile.txt%char(34)}


Nothing works.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jun 28, 2009 2:37 am   
 
Come on Guru people help me out here. Razz
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Sun Jun 28, 2009 4:37 am   
 
I fail to see how your last 2 examples are the same...

As for a simpler solution..... make a folder C:\muddingstuff\testfile.txt and use that?

I think that part of the problem is how windows/notepad remembers the working directory, in all but the 2n'd from last example you were relying on the working directory to be the same. the current directory for cmud is different from what notepad is...

Also xp/vista behave fairly differently here.

Code:
#launch {notepad.exe somefilethatdontexist.txt}


In both cases brings up notepads this file don't exist box, but on vista, it still didn't create the file, it left me with an untitled document, XP made the file for me.
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jun 28, 2009 4:48 am   
 
Because "C:\Documents and Settings\XXXX\My Documents\My Games\CMUD\Packages\testfile.txt" is an absolute path and "..\..\..\..\CMUD\Packages\testfile.txt" is a relative path so how are they not the same as in referring to the same place?

You miss the point entirely. If I use this package on different computers and let other people use it I cannot make an absolute file path. The other computer may not have the same directory.

I'm not sure why when you did launch it created a new file. It doesn't do that for me and isn't supposed to is it?
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Sun Jun 28, 2009 6:49 am   
 
Quote:
So I tried the absolute path.

Code:
#launch {"notepad.exe" %char(34)C:\Documents and Settings\XXXX\My Documents\My Games\CMUD\Packages\testfile.txt%char(34)}


It then opens it.

However, the failure here is that the following refers to the same thing and it cannot find the file.

Code:
#launch {"notepad.exe" %char(34)..\..\..\..\CMUD\Packages\testfile.txt%char(34)}


Nothing works.


Sounds to me like you think they should both open up the same file....

Relative file paths start in the current working directory and build from there, absolute are well absolute

Your last example... well i'm not sure exactly where it would put you.

I did see, but forgot you were looking for something use this from different computers, the only way I know to do that is to access the windows registry, and get the value of the zuggsoft\cmud\datadir entry.... or since your going to have to add this package to the computer you put a c:\mudgames\ folder on the harddrive.

Windows vista and windows xp act entirely differently here, vista, with just a filename does not create the file, vista with an absolute path does, xp does for me.
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jun 28, 2009 8:41 am   
 
Well whatever. So how exactly do you get it to open the damn file once it creates it when it can't even find it.
Reply with quote
wrym
Magician


Joined: 06 Jul 2007
Posts: 349
Location: The big palace, My own lil world

PostPosted: Sun Jun 28, 2009 10:14 am   
 
wow.... stupid simple solution

Code:
<trigger priority="15370" id="1537">
  <pattern>^Closed (*) on file 2$</pattern>
  <value>#launch {notepad.exe %1}</value>
</trigger>
_________________
"To the engineer, all matter in the universe can be placed into one of two categories: (1) things that need to be fixed, and (2) things that will need to be fixed after you've had a few minutes to play with them" - Scott Adams, The Dilbert Principle
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Sun Jun 28, 2009 11:23 am   
 
Haha oh god. That was simple.

I'm going to go beat myself in the head now...
Reply with quote
Arde
Enchanter


Joined: 09 Sep 2007
Posts: 605

PostPosted: Sun Jun 28, 2009 6:40 pm   
 
wrym wrote:
the only way I know to do that is to access the windows registry, and get the value of the zuggsoft\cmud\datadir entry.

May be Zugg will add, say, %datafolder predefined variable to use it in a script?..
_________________
My personal bug|wish list:
-Wrong Priority when copy-paste setting
-1 prompt trigger for Mapper, Session and General Options, not 3 different!
-#SECTION can terminate threads
-Buttons can't start threads
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net