PDA

View Full Version : How can I delete a character in a text file?


PereBalsach
07-08-2007, 03:16 AM
Hi,
Anyone know how can I delete one or more characters in a text file with mel?


My problem is:

I have a textScrollList and I'm writing all the data in the List to a text file.

I'm writing each string with a "\n" at the end to enter a new line. Ok, thats what I want.

But...I don't want the last "\n" becouse the next time that I will write data to the text file I will have a space between the text from the last fprint to the new fprint.
Do you know what I mean? :)

Thanks in advice!


for ($i=0; $i<(`textScrollList -q -ni pathList`) ; $i++){
fprint $fileId ($NewpathLine[$i] + "\n");
}

mhovland
07-09-2007, 01:31 PM
for ($i=0; $i<(`textScrollList -q -ni pathList`) ; $i++){

if($i==(`textScrollList -q -ni pathList` - 1))
fprint $fileId ($NewpathLine[$i]);
else
fprint $fileId ($NewpathLine[$i] + "\n");
}



That should work......Test it and let me know, I'm not in front of Maya ATM.

PereBalsach
07-09-2007, 05:31 PM
Thanks man!

I found an easy solution. It works a treat :thumbsup:


string $FileTextLine = `fgetline $fileId`;
$FileTextLine = `substitute "\n" $FileTextLine ""`;


Easy as a piece of cake isn't it?
Thanks anyway dude!

CGTalk Moderation
07-09-2007, 05:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.