chewy Posted February 8, 2005 Author Posted February 8, 2005 Func _RemoveLeadingCharsFromFile($sInFile, $sOutFile, $iRemoveChars) Local $sAll, $hFile $sAll = FileRead($sInFile, FileGetSize($sInFile)) $hFile = Fileopen($sOutFile, 2) FileWrite($hFile, stringmid($sAll, $iRemoveChars + 1,filegetsize($sInFile))) FileClose($hFile) EndFunc remember i am new at this
phillip123adams Posted February 8, 2005 Posted February 8, 2005 chewy said: Func _RemoveLeadingCharsFromFile($sInFile, $sOutFile, $iRemoveChars) Local $sAll, $hFile $sAll = FileRead($sInFile, FileGetSize($sInFile)) $hFile = Fileopen($sOutFile, 2) FileWrite($hFile, stringmid($sAll, $iRemoveChars + 1,filegetsize($sInFile))) FileClose($hFile)EndFuncremember i am new at this <{POST_SNAPBACK}>New's okay! Good try, had me going for a few seconds. The problem is that when the output file is opened, it is necessarily opened in write mode, which means it erases every thing in the existing file. As such, FileGetSize returns zero when used at the point you are using it.If you want to specify the count, or you are not using the latest version of AutoIt, here's the revised function:Func _RemoveLeadingCharsFromFile($sInFile, $sOutFile, $iRemoveChars) Local $sAll, $hFile, $iSize $iSize = FileGetSize($sInFile) $sAll = FileRead($sInFile, $iSize) $hFile = Fileopen($sOutFile, 2) FileWrite($hFile, stringmid($sAll, $iRemoveChars + 1, $iSize)) FileClose($hFile) EndFunc Phillip
chewy Posted February 8, 2005 Author Posted February 8, 2005 Thanks! works perfect now! thanks for the help!
phillip123adams Posted February 8, 2005 Posted February 8, 2005 chewy said: Thanks! works perfect now! thanks for the help! <{POST_SNAPBACK}>You're welcome. Phillip
chewy Posted August 22, 2005 Author Posted August 22, 2005 another question about this. Now I also need to erase the last character in the file.This is what I use to delete the first 2 characters and it work perfect Quote Func _RemoveLeadingCharsFromFile($sInFile, $sOutFile, $iRemoveChars) Local $sAll, $hFile $sAll = FileRead($sInFile, FileGetSize($sInFile)) $hFile = Fileopen($sOutFile, 2) FileWrite($hFile, stringmid($sAll, $iRemoveChars + 1,filegetsize($sInFile))) FileClose($hFile)EndFuncnow I need to delete out the last character in the file.Any ideas?
GaryFrost Posted August 22, 2005 Posted August 22, 2005 StringTrimRight SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
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