1 registered members (AndrewAMD),
1,089
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
deleting the last character from a txt file?
#133246
06/02/07 08:08
06/02/07 08:08
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
Hey guys, I'm having a real messed up problem... I can't seem to find a solution.. I've been writing variables to a file the problem is i'm having this really nasty bug in my game when I read the file back because I always end up having a space at the end (i need to use space as the delimit_str).
file_var_write always puts a space after whatever it puts in...
I need to get rid of the last character in my text file in order to fix this problem. Is there anyway to do this? I tried using ascii character 8 (backspace) but all it does is print some stupid character...
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: deleting the last character from a txt file?
[Re: Xarthor]
#133248
06/02/07 14:55
06/02/07 14:55
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
ya it looks like it will... but my question is will this have a limit? Like upto how many characters can I copy with this method? I know strings are stupid and can only hold like 7000 or 70000 or something like that...
but for now.. if this works... it'll be fine! thanks
edit: Okay, I read the manual... but it's still not to clear to me the way txt_load works. file_str_read has a 4000 character max... does this mean... if i use txt_load, after the 4000 characters of one string is filled up it'll carry on to the next string, assuming of course I have more then 1 string in the text object?
Last edited by PrenceOfDarkness; 06/02/07 16:37.
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: deleting the last character from a txt file?
[Re: PrenceOfDarkness]
#133249
06/02/07 17:23
06/02/07 17:23
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
alos I tried using bigdll.. but it doesn't seem to be working.. i included <FreeDll.wdl>;
and typed in: temp = DllGetLengthFromFile("data.txt"); temp -= 3; DllEreaseBytes(temp,3,"data.txt");
and nothing happened.... Then i tried to see if DllEreaseBytes worked at all and i tried: temp = DllGetLengthFromFile("data.txt"); temp -= 3; DllEreaseBytes(1,100,"data.txt");
nothing happened again.. can someone help out with this? What am i doing wrong?
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
Re: deleting the last character from a txt file?
[Re: PrenceOfDarkness]
#133250
06/02/07 18:09
06/02/07 18:09
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
i guess this problem (a space at the end of the file) is because delemit_str is a space. Have you already tried to set the delemit_str to "" before you write the last var into you file? Then you wont get a space at the end, maybe. (Ive never tested ) nipx
|
|
|
Re: deleting the last character from a txt file?
[Re: nipx]
#133251
06/02/07 23:32
06/02/07 23:32
|
Joined: Mar 2006
Posts: 2,503 SC, United States
xXxGuitar511
Expert
|
Expert
Joined: Mar 2006
Posts: 2,503
SC, United States
|
He already said he needed the delimeter str as a space. However, I guess he could set it to null, and then manually add a delimiter where needed...
xXxGuitar511 - Programmer
|
|
|
Re: deleting the last character from a txt file?
[Re: xXxGuitar511]
#133252
06/03/07 00:05
06/03/07 00:05
|
Joined: Dec 2005
Posts: 252 MyOwnKingdom
nipx
Member
|
Member
Joined: Dec 2005
Posts: 252
MyOwnKingdom
|
Yes, I know he needs delimit_str=" " but he could set it to "" after he wrote the second last var and before the last one: something like: Code:
...... str_cpy(delimit_str, " "); file_var_write(handle, a); file_var_write(handle, b); file_var_write(handle, c); file_var_write(handle, d); //there's a " " after every var str_cpy(delimit_str, ""); //but not after the very last one file_var_write(handle, e); .......
As I told, Ive not tested, its just a little hint... nipx
|
|
|
Re: deleting the last character from a txt file?
[Re: nipx]
#133253
06/03/07 04:49
06/03/07 04:49
|
Joined: Aug 2004
Posts: 1,305 New York
PrenceOfDarkness
OP
Serious User
|
OP
Serious User
Joined: Aug 2004
Posts: 1,305
New York
|
hey guys, thanks alot for all your help.. but I decided to rewrite my entire code so that I didn't have to worry about what it said at the end... I was trying to optimize the script and how fast it ran, i learned my lesson "If it aint broke... don't fix it ) Working with 3dgamestudio is like having a relationship.... with a drunk hooker... better yet... more like a toilet , come on.. i know the ones who've been around since A5 or older know what i'm talking about Anyways thanks for your help but I wont be needing you guys to waste your brain power on me anymore
"There is no problem that can't be solved with time and determination." -me prenceofdarkness for instant messages on AIM.
Looking for a model designer PLEASE, SEND ME A PRIVATE MESSAGE OR EMAIL IF YOU'RE INTERESTED.
|
|
|
|