CodyBarrett Posted May 15, 2009 Share Posted May 15, 2009 im pretty sure i've posted something like this before but cannot find where... alright what im trying to do.. i have a chatroom that runs off of a file.. multiple PCs use this one file.. and its read often, and im working on a Personalmessenger which is Easy with TCP.. but somehow more difficult using a file the way it works.. Runs app > reads file(Currently hex format) > hextostring(File) > Stringsplit (@CRLF) > and then For $i = 1 to stringsplit value guictrlsetdata (main edit, stringsplit value[$i]) next and that works fine.. just when i start adding Pm's that i don't want others to view... the pm type looks like this "º!Name Message-From*º" now if it isn't your PM.. the app replaces this as "" in the Main edit control.... trouble is.. if it IS your PM... i want it to replace the pm string in the file and rewrite it with the string removed.... i have this.. and its not working would anyone know how to do it? _stringreplaceinfile or whatever its called doesn't work because file is written in Hex $File = FileRead($S_TXT) $File = _HexToString($File) $File = StringSplit($File, 'º') For $i = 1 To $File[0] If StringInStr($File[$i], '!' & $Name_S) Then $Pm = _StringBetween($File[$i], '!' & $Name_S, '-') $From = _StringBetween($File[$i], '-', '*') $sFile = FileRead($S_TXT) $sFile = _HexToString($sFile) $sFile = StringReplace($sFile, @CRLF & 'º!' & $Name_S & _StringBetween ($File[$i], $Name_S, '*º') & '*º' & @CRLF, '') $sFile = _StringToHex($sFile) FileDelete($S_TXT) FileWrite($S_TXT, $sFile) MsgBox (0,'', $Pm[0]) EndIf If StringLeft($File[$i], 1) = '!' Then $File[$i] = '' If StringLeft($File[$i], 1) = '$' Then $File[$i] = '' If StringLeft($File[$i], StringLen($Ignore)) = $Ignore Then $File[$i] = '' GUICtrlSetData($Main, GUICtrlRead($Main) & $File[$i]) Next any ideas? i've been stuck on this for a few weeks now but been to busy with other projects to post until now [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
oMBRa Posted May 15, 2009 Share Posted May 15, 2009 post an example of what's your file like, showing how u want change it Link to comment Share on other sites More sharing options...
toonboon Posted May 15, 2009 Share Posted May 15, 2009 (edited) _StringBetween returns an array. $File = FileRead($S_TXT) $File = _HexToString($File) $File = StringSplit($File, 'º') For $i = 1 To $File[0] If StringInStr($File[$i], '!' & $Name_S) Then $Pm = _StringBetween($File[$i], '!' & $Name_S, '-') $Pm = $Pm[0] $From = _StringBetween($File[$i], '-', '*') $From = $From[0] $sFile = FileRead($S_TXT) $sFile = _HexToString($sFile) $Msg = _StringBetween ($File[$i], $Name_S, '*º') $sFile = StringReplace($sFile, @CRLF & 'º!' & $Name_S & $Msg[0] & '*º' & @CRLF, '') $sFile = _StringToHex($sFile) FileDelete($S_TXT) FileWrite($S_TXT, $sFile) MsgBox (0,'', $Pm[0]) EndIf If StringLeft($File[$i], 1) = '!' Then $File[$i] = '' If StringLeft($File[$i], 1) = '$' Then $File[$i] = '' If StringLeft($File[$i], StringLen($Ignore)) = $Ignore Then $File[$i] = '' GUICtrlSetData($Main, GUICtrlRead($Main) & $File[$i]) Next I think this should work... EDIT: Edited in my double post xD Edited May 15, 2009 by toonboon [right]~What can I say, I'm a Simplistic person[/right] Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 15, 2009 Author Share Posted May 15, 2009 (edited) lmao i hate double posts.. happens to me all the time... alright here is what the .txt is like.. NORMAL text.. how i see it in the Chat Global Message < Test > | < barrettc > Has Connected ! Test > Test and now what the .txt looks like 0D0ABA476C6F62616C204D657373616765203C2054657374203E207C203C206261727265747463203E202048617320436F6E 6E65637465642021BA0D0A0D0ABA546573742020203E2020202054657374BA0D0A0D0ABA476C6F62616C204D657373616765 203C2054657374203E2048617320446973636F6E6E6563746564202EBA0D0A EDIT it doesn't even work when i use Stringmid() _stringbetween() i know it uses an array Edited May 15, 2009 by CodyBarrett [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
oMBRa Posted May 15, 2009 Share Posted May 15, 2009 (edited) lmao i hate double posts.. happens to me all the time... alright here is what the .txt is like.. NORMAL text.. how i see it in the Chat and now what the .txt looks like 0D0ABA476C6F62616C204D657373616765203C2054657374203E207C203C206261727265747463203E202048617320436F6E 6E65637465642021BA0D0A0D0ABA546573742020203E2020202054657374BA0D0A0D0ABA476C6F62616C204D657373616765 203C2054657374203E2048617320446973636F6E6E6563746564202EBA0D0A EDIT it doesn't even work when i use Stringmid() _stringbetween() i know it uses an arraywhat should be replaced?, I saw in your script that u search for '-' but I can't see it anywhere in your txt example Edited May 15, 2009 by oMBRa Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 15, 2009 Author Share Posted May 15, 2009 im looking to replace everything from the PM with "" like !Tothem Mymessage-Frommyname* -----> "" but to save it and view it later on when the user wants.... like i said its MUCH easyer with TCP and im kinda thinking ofjust excluding this from the app [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
oMBRa Posted May 15, 2009 Share Posted May 15, 2009 sorry but I still dont understand what your file looks like... first u said it is like this:ºGlobal Message < Test > | < barrettc > Has Connected !ººTest > TestººGlobal Message < Test > Has Disconnected .ºnow u said !Tothem Mymessage-Frommyname* Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 15, 2009 Author Share Posted May 15, 2009 this is what the File is in...0D0ABA476C6F62616C204D657373616765203C2054657374203E207C203C206261727265747463203E202048617320436F6E6E65637465642021BA0D0A0D0ABA546573742020203E2020202054657374BA0D0A0D0ABA476C6F62616C204D657373616765203C2054657374203E2048617320446973636F6E6E6563746564202EBA0D0Athis is what the hextostring givesºGlobal Message < Test > | < barrettc > Has Connected !ººTest > Testºand this is waht i see on the main EditGlobal Message < Test > | < barrettc > Has Connected !Test > Testthis is an exxample of the PM... IN the Fileº!ToName Message-FromName*ºit strips the "º" somewhere else in the script [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] Link to comment Share on other sites More sharing options...
oMBRa Posted May 15, 2009 Share Posted May 15, 2009 u mean something like this ? #include <String.au3> $String = 'BA21546F4E616D65204D6573736167652D46726F6D4E616D652ABA' $String = 'example'&@CRLF&'º!ToName Message-FromName*º'&@CRLF&'example2'&@CRLF&'º!ToName Message-FromName*º'&@CRLF&'example3' $String = _StringToHex($String) $String = _HexToString($String) $String = StringRegExpReplace($String, 'º!.+\*º', '') MsgBox(0, '', $String) Link to comment Share on other sites More sharing options...
CodyBarrett Posted May 15, 2009 Author Share Posted May 15, 2009 that above seems to work... ima look into regexreplace.... lol thanks [size="1"][font="Tahoma"][COMPLETED]-----[FAILED]-----[ONGOING]VolumeControl|Binary Converter|CPU Usage| Mouse Wrap |WinHide|Word Scrammbler|LOCKER|SCREEN FREEZE|Decisions Decisions|Version UDF|Recast Desktop Mask|TCP Multiclient EXAMPLE|BTCP|LANCR|UDP serverless|AIOCR|OECR|Recast Messenger|AU3C|Tik-Tak-Toe|Snakes & Ladders|BattleShips|TRON|SNAKE_____________________[u]I love the Helpfile it is my best friend.[/u][/font][/size] 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