aommaster Posted August 1, 2007 Share Posted August 1, 2007 (edited) Hi guys!The title basically says it all!I have a script which is basically is a hangman player. It guesses letters and then inputs the clue (letters and dashes) and puts it in the following form:*****.O*.*.F******.F*O**.*O******The dots really are spaces, but I've put them in because for some reason, Autoit tends to ignore spaces. All *'s stand for a single letter.Now, my text file actually divides the answers in terms of number of words, so it looks something like this:3 Hi.to.everyone 4 This.is.a.test Welcome.to.the.solutionsThis carries on all the way down to around 15 word solutions.What my script can do is count the number of words in the string (I did this by counting the number of replacements of three spaces needed and then added 1).So, as I see it, there are two ways to get the solution:1.Test each and EVERY line and see if it matches the string required. I think this is quite inefficient.2.Count the number of words, and find the line in the text file that has that number, and just read below that line.Either way, I need it to use the *'s as wildcards that can contain any letter.So far, all I can see that StringCompare can do is to compare two strings for an exact match, and not use wild cards at all, and I was wondering whether there was a way around that.Please don't tell me to use arrays, because it would mean that I would need to re-write out my whole script - not fun!edit: Just removed some typosThanks a lot for your time guys! Edited August 1, 2007 by aommaster Link to comment Share on other sites More sharing options...
qazwsx Posted August 1, 2007 Share Posted August 1, 2007 i think its better to use question marks as wild cards for a single letter. I don't think that asterisks have a limit for the number of letters, but im no totally sure. Link to comment Share on other sites More sharing options...
aommaster Posted August 1, 2007 Author Share Posted August 1, 2007 (edited) Hmm... I think so, I was reading about it somewhere in the manual. But that's not my point. I don't know how to use wildcards in Stringcompare...full stop I'm not even sure whether stringcompare recognises wild cards...Edit: I just checked... and no, it doesn't Edited August 1, 2007 by aommaster Link to comment Share on other sites More sharing options...
qazwsx Posted August 1, 2007 Share Posted August 1, 2007 I don't understand what you are going to use string compare for. Link to comment Share on other sites More sharing options...
aommaster Posted August 1, 2007 Author Share Posted August 1, 2007 I don't understand what you are going to use string compare for.Well, let's say that I have a clue which contains some letters of the original solution. Filling in the spaces with wildcards, and using stringcompare to a text file that contains all possible solutions, autoit will allow me to quickly find the right answer. Link to comment Share on other sites More sharing options...
qazwsx Posted August 1, 2007 Share Posted August 1, 2007 maybe you could use a stringsplit and compare one letter at a time. If the one character is a wildcard then don't run it through the stringcompare. Link to comment Share on other sites More sharing options...
aommaster Posted August 1, 2007 Author Share Posted August 1, 2007 maybe you could use a stringsplit and compare one letter at a time. If the one character is a wildcard then don't run it through the stringcompare.You know what, I was actually considering doing that in a slightly different way, which was actually sticking both strings into an array. But surely there's got to be another, quicker way! Link to comment Share on other sites More sharing options...
qazwsx Posted August 1, 2007 Share Posted August 1, 2007 i think that would be the quickest way actually. because it would only have to compare one character for each string. That way it wont compare characters if that string cannot possibly be the answer. Link to comment Share on other sites More sharing options...
aommaster Posted August 1, 2007 Author Share Posted August 1, 2007 i think that would be the quickest way actually. because it would only have to compare one character for each string. That way it wont compare characters if that string cannot possibly be the answer.Oh dear me... I'll take a shot at it, but it's quite likely I'll be having trouble with the code Oh well, it's a learning experience for me, so I really don't mind Thanks again! 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