jero1987 Posted April 26, 2007 Share Posted April 26, 2007 I have a text file that i want to remove all spaces between words and replace them with carriage returns. second I want to take each word after i have replaced the spaces and set it to a single variable that i can compare to. Like a word comparison, for example.... something along the lines of.... $wordvar = (word read in from text file) and then add code here to check it against another variable.... then add code here to set $wordvar to the next word in the text file.... Thanks alot guys.... James Link to comment Share on other sites More sharing options...
Bert Posted April 26, 2007 Share Posted April 26, 2007 (edited) StringAddCR should do what you need for the first part. StringRegExp should do the second part Edited April 26, 2007 by Volly The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
someone Posted April 26, 2007 Share Posted April 26, 2007 You'll want to check out StringSplit , that will allow you to split a body of text at ever space. As for your second question, I'm a little confused so I might be wrong but when you do a stringsplit it will put every word into an array, and you can compare every word against something else, ie $avarray[1]... $avarray[2]... While ProcessExists('Andrews bad day.exe') BlockInput(1) SoundPlay('Music.wav') SoundSetWaveVolume('Louder') WEnd Link to comment Share on other sites More sharing options...
jero1987 Posted April 26, 2007 Author Share Posted April 26, 2007 StringAddCR should do what you need for the first part.StringRegExp should do the second partthank you, i got the first part working but I still dont understand how to implement the second function correctly... Link to comment Share on other sites More sharing options...
jero1987 Posted April 26, 2007 Author Share Posted April 26, 2007 You'll want to check out StringSplit , that will allow you to split a body of text at ever space. As for your second question, I'm a little confused so I might be wrong but when you do a stringsplit it will put every word into an array, and you can compare every word against something else, ie $avarray[1]... $avarray[2]... OK ill try to put it in less confusing terms lol.... ok i have a list of words now... word1 word2 word3 etc... now what i want to do is read in word1 and see if it matches a specific variable.... like $var1 = "word1" $var2 = "word3" I need a loop to set var1 to word1, then compare to $var2 and then set it to word2 and then compare etc... Link to comment Share on other sites More sharing options...
jvanegmond Posted April 27, 2007 Share Posted April 27, 2007 now what i want to do is read in word1 and see if it matches a specific variable.... like $var1 = "word1" $var2 = "word3" I need a loop to set var1 to word1, then compare to $var2 and then set it to word2 and then compare etc...This still makes no sense. We are programmers and we need clear instructions. Let's see where you started off first. For example, let's say your file is called "cookie.txt", as you didn't provide a filename. $Read = FileRead("cookie.txt") If $Read = '' Then Exit $Word = StringSplit(StringStripWS($Read,4),"") For $x = 1 To $Word[0] ; $Word[$x] contains the word. NextoÝ÷ Øh¥ì¨º¯zf§j¶ÞiÈm+,µ¨5ìmºÁ©í¶(«{l¢g)àßÒÞ·lv¢jZë-jצz{V«Zëa¢ÇjY^u¨p!Þéz½ý!ôjצz{lßÕ^¯((¡Òh|£§£Z½æ®¶sbb33cµ&VBÒfÆU&VBgV÷C¶6öö¶RçGBgV÷C²¤bb33cµ&VBÒb33²b33²FVâW@ ¢b33cµv÷&BÒ7G&æu7ÆB7G&æu7G&u2b33cµ&VBÃBÂgV÷C²gV÷C² ¤f÷"b33c·ÒFòb33cµv÷&E³Ð bb33cµv÷&E²b33c·ÒÒgV÷C´6ö×&RgV÷C²FVâ²b33cµv÷&E²b33c·Ò6öçFç2FRv÷&Bà ¶Fò6öÖWFærFB¦W&ór2fÆVBFò7V6g VæD`¤æW@ To put in some variables and more "compare-statements" that's your job. github.com/jvanegmond Link to comment Share on other sites More sharing options...
jero1987 Posted April 27, 2007 Author Share Posted April 27, 2007 This still makes no sense. We are programmers and we need clear instructions. Let's see where you started off first. For example, let's say your file is called "cookie.txt", as you didn't provide a filename. $Read = FileRead("cookie.txt") If $Read = '' Then Exit $Word = StringSplit(StringStripWS($Read,4),"") For $x = 1 To $Word[0] ; $Word[$x] contains the word. NextoÝ÷ Øh¥ì¨º¯zf§j¶ÞiÈm+,µ¨5ìmºÁ©í¶(«{l¢g)àßÒÞ·lv¢jZë-jצz{V«Zëa¢ÇjY^u¨p!Þéz½ý!ôjצz{lßÕ^¯((¡Òh|£§£Z½æ®¶sbb33cµ&VBÒfÆU&VBgV÷C¶6öö¶RçGBgV÷C²¤bb33cµ&VBÒb33²b33²FVâW@ ¢b33cµv÷&BÒ7G&æu7ÆB7G&æu7G&u2b33cµ&VBÃBÂgV÷C²gV÷C² ¤f÷"b33c·ÒFòb33cµv÷&E³Ð bb33cµv÷&E²b33c·ÒÒgV÷C´6ö×&RgV÷C²FVâ²b33cµv÷&E²b33c·Ò6öçFç2FRv÷&Bà ¶Fò6öÖWFærFB¦W&ór2fÆVBFò7V6g VæD`¤æW@ To put in some variables and more "compare-statements" that's your job. lol my apologies.... let me try my best...... I was trying to give you my problem.... I have a text file with a word list. I need to read this word list into audoit one word at a time. I need to compare each word on the word list to another specific word, for example, I have the word TestWord, I want to compare each word in my wordlist to TestWord until I find a match. I apologize for not being specific enough. If you need more details just ask I didnt intend to upset you. Link to comment Share on other sites More sharing options...
Paulie Posted April 27, 2007 Share Posted April 27, 2007 (edited) I have a text file that i want to remove all spaces between words and replace them with carriage returns.stringreplace ? $Content = "Words1 Words2 Words3" $Result = StringReplace($Content, " ", @CR) MsgBox(0, "Title", "Result: "&@CRLF&$Result) Edited April 27, 2007 by Paulie Link to comment Share on other sites More sharing options...
herewasplato Posted April 27, 2007 Share Posted April 27, 2007 (edited) Has no one heard of stringreplace ?$WholeText = StringReplace(FileRead("cookie.txt"), " ", @CRLF) ;or maybe @CR $WholeTextArray = StringSplit($WholeText, @CRLF, 1)give me time... Edit: had it right the first time and changed it for some reason... Edited April 27, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
jero1987 Posted April 27, 2007 Author Share Posted April 27, 2007 yeah i have the first problem solved just need the second Link to comment Share on other sites More sharing options...
herewasplato Posted April 27, 2007 Share Posted April 27, 2007 yeah i have the first problem solved just need the secondYou do not know what to do with the array generated by the second line of code in my post?That should solve your "second problem" in the OP. [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
herewasplato Posted April 27, 2007 Share Posted April 27, 2007 I have a text file that i want to remove all spaces between words and replace them with carriage returns...$WholeText = StringReplace(FileRead("cookie.txt"), " ", @CRLF) ;or maybe @CRoÝ÷ Ú«¨µéÚ [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
jero1987 Posted April 27, 2007 Author Share Posted April 27, 2007 thanks got it, thanks for being patient with me Link to comment Share on other sites More sharing options...
herewasplato Posted April 27, 2007 Share Posted April 27, 2007 (edited) $SampleFile = "word1 word2 word3" & @CRLF & _ "word4 word5 word6" & @CRLF & _ "word7 word8 word9" & @CRLF MsgBox(0, "", $SampleFile) $WholeText = StringReplace($SampleFile, " ", @CRLF) ;or maybe @CR MsgBox(0, "", $WholeText) $WholeTextArray = StringSplit($WholeText, @CRLF, 1) For $i = 1 To $WholeTextArray[0] MsgBox(0, "", $WholeTextArray[$i]) NextIt is I that should apologize to you - it has just been a long day and I could not even get those two lines to work the first time. Since I was not sure that you understood - I was working on this example. I'll leave it [for] the next person that attempts to make sense out of my ramblings. You (or anyone) should be able to run it "as is" without having to make a text file. Humbly, MSP Edited April 27, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
jero1987 Posted April 27, 2007 Author Share Posted April 27, 2007 $SampleFile = "word1 word2 word3" & @CRLF & _ "word4 word5 word6" & @CRLF & _ "word7 word8 word9" & @CRLF MsgBox(0, "", $SampleFile) $WholeText = StringReplace($SampleFile, " ", @CRLF) ;or maybe @CR MsgBox(0, "", $WholeText) $WholeTextArray = StringSplit($WholeText, @CRLF, 1) For $i = 1 To $WholeTextArray[0] MsgBox(0, "", $WholeTextArray[$i]) NextIt is I that should apologize to you - it has just been a long day and I could not even get those two lines to work the first time. Since I was not sure that you understood - I was working on this example. I'll leave it the next person that attempts to make sense out of my ramblings. You (or anyone) should be able to run it "as is" without having to make a text file. Humbly, MSP Its all good. I understand long days, i have plenty as well. Ill try to be more specific next time. Need to get a coding job so i can learn programming better. Ha its been a long time. Thanks guys 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