Sign in to follow this  
Followers 0
jero1987

2 coding questions

15 posts in this topic

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

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

StringAddCR should do what you need for the first part.

StringRegExp should do the second part

thank you, i got the first part working but I still dont understand how to implement the second function correctly...

Share this post


Link to post
Share on other sites

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...

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#8 ·  Posted (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 by Paulie

Share this post


Link to post
Share on other sites

#9 ·  Posted (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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

yeah i have the first problem solved :shocked: just need the second

Share this post


Link to post
Share on other sites

yeah i have the first problem solved :shocked: just need the second

You 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]

Share this post


Link to post
Share on other sites

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]

Share this post


Link to post
Share on other sites

thanks got it, thanks for being patient with me

Share this post


Link to post
Share on other sites

#14 ·  Posted (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])
Next
It 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 by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

Share this post


Link to post
Share on other sites

$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])
Next
It 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

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0