Pharo Posted January 28, 2009 Share Posted January 28, 2009 I'm try to get a value ($line) to increase by 1 and then write over the old value. It will read the number correctly, add 1 to it correctly but won't write it. CODE $line = FileReadLine("items.txt",3) $line=$line+1 _FileWriteToLine("items.txt", 3,($a), 0) Link to comment Share on other sites More sharing options...
Authenticity Posted January 28, 2009 Share Posted January 28, 2009 Try to play around with the _WinAPI_* functions as they use the pure (or close to pure) API call. Like: _WinAPI_SetFilePointer, _WinAPI_WriteFile etc.. Link to comment Share on other sites More sharing options...
Skruge Posted January 28, 2009 Share Posted January 28, 2009 Welcome to the forums. $a isn't defined anywhere in your code. If you check @error after the _FileWriteLine call, you'll see that the text is invalid. Apparently the function wants an actual string, not an integer. You can get around this by converting it. Also, to replace the line (not insert), set the fourth parameter to 1. Try this:$line = FileReadLine("items.txt", 3) $line = $line + 1 _FileWriteToLine("items.txt", 3, String($line), 1) [font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font] Link to comment Share on other sites More sharing options...
Authenticity Posted January 28, 2009 Share Posted January 28, 2009 Also, for the purpose of your problem try to build the file's line like this 'Item.txt|54' and use the following methods: Opt('MustDeclareVars', 1) Dim $sLine = 'Items.txt|53' Dim $Arr $Arr = StringSplit($sLine, '|') $Arr[2] = '128' $sLine = $Arr[1] & '|' & $Arr[2] FileWrite('Weapons.txt', $sLine) Or something similar... Link to comment Share on other sites More sharing options...
Pharo Posted January 28, 2009 Author Share Posted January 28, 2009 Thanks you all so much, that fixed all of my problems Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now