Blue Eye Logo

Blue Eye Macro

Automation is freedom
It is currently Tue Dec 03, 2024 5:28 pm

All times are UTC




Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Mon May 24, 2010 10:03 pm 
Lifetime VIP Contributor
Lifetime VIP Contributor
User avatar



Joined: Sat Apr 24, 2010 12:51 pm
Posts: 355
Location: Tallinn
Been thanked: 18 time(s)
Has thanked: 1 time(s)
Contribution Points: 4647
I though to try to make macro to randomly choose word/name from the txt file
for this ive made:
Code:
 begin
     File.Read text("C./macro/input.txt", "input")
missing part
     File.Write text("C:/macro/output.txt", "no", "{result}")
 end
'

since theres no variable.get random line or something is there anything else to use?

this would be for those who uses 10s and 10s of different names in games/accounts, and just for the next one it would choose it for you :)

as if the input has:
GlobalWarming
CowsNgrass
Boozy

the output would randomly choose 1 line as the result

ive tryed with Variable.Set random text as variables from the "get first line, get next line and so on" but it took 1 line, and randomed the orders of the letters (as it should supposed to do)
tryed some other things also, but didnt get the result to pick 1 from the list.

_________________
Full time IT student/worker - BE showed me the way, so may the code be with you all!
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Mon May 24, 2010 11:42 pm 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
Perhaps ill extend the File category, to include a File.Read Line("lineNumber"),

then you could simply generate a random lineNumber between 1 and the number of elements in the list.

For now, id suggest something like generating a random number called "number", and then do a begin loop("{number}")
and inside that loop do a File.Read next line..

That would give you what you need.

Kinda messy way though :/

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:17 am 
Lifetime VIP Contributor
Lifetime VIP Contributor
User avatar



Joined: Sat Apr 24, 2010 12:51 pm
Posts: 355
Location: Tallinn
Been thanked: 18 time(s)
Has thanked: 1 time(s)
Contribution Points: 4647
yep it worked:

Code:
 begin
     File.Read first line("C:/macro/input.txt", "1stline")
     Variable.Set random number("randomnumb", "0", "20")
     begin loop("{randomnumb}")
          File.Read next line("C:/macro/input.txt", "input")
     end
     if  Variable.Exists("input")
          and
          Variable.Is not empty("input")
          begin
               File.Write text("C:/macro/output.txt", "no", "{input}")
          end
     If  Variable.Is empty("input")
          begin
               Macro.Restart()
          end
 end
 


tho im facing some problem, as:

whidout "variable.read first line" it writes only " ", so to take 1st word to random you need to add "enter" to the start of the file (so the loops only takes from 2nd line where the words start)

im trying to think out the way to add "enter" to the text

i have for it
Code:
begin
     File.Read text("C:/macro/test.txt", "txt")
     Variable.Evaluate (Text)("{<enter>}{txt}", "txt2")
     File.Write text("C:/macro/test.txt", "no", "{txt2}")
 end

but the enter is not the right thing to put there..

_________________
Full time IT student/worker - BE showed me the way, so may the code be with you all!
Image


Last edited by BakT on Tue May 25, 2010 8:24 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:21 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
saintsant wrote:
yep it worked:

Code:
...


tho im facing some problem, as:

whidout "variable.read first line" it writes only " ", so to take 1st word to random you need to add "enter" to the start of the file (so the loops only takes from 2nd line where the words start)


Since your random generates a number between 0 and 20,
the loop might not run at all, if the number generated is 0.

just change your code so the first line is saved in the same variable as the following lines.

And you wont have to add a empty line in your document.

Like this:
Code:
begin
     File.Read first line("C:/macro/input.txt", "input")
     Variable.Set random number("randomnumb", "0", "20")
     begin loop("{randomnumb}")
          File.Read next line("C:/macro/input.txt", "input")
     end
     if  Variable.Exists("input")
          and
          Variable.Is not empty("input")
          begin
               File.Write text("C:/macro/output.txt", "no", "{input}")
          end
     If  Variable.Is empty("input")
          begin
               Macro.Restart()
          end
end

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:26 am 
Lifetime VIP Contributor
Lifetime VIP Contributor
User avatar



Joined: Sat Apr 24, 2010 12:51 pm
Posts: 355
Location: Tallinn
Been thanked: 18 time(s)
Has thanked: 1 time(s)
Contribution Points: 4647
oh i see, now it should take 1st line
Code:
 begin
     File.Read first line("C:/macro/input.txt", "input")
     Variable.Set random number("randomnumb", "0", "20")
     begin loop("{randomnumb}")
          File.Read next line("C:/macro/input.txt", "input")
     end
     if  Variable.Exists("input")
          and
          Variable.Is not empty("input")
          begin
               File.Write text("C:/macro/output.txt", "no", "{input}")
          end
     If  Variable.Is empty("input")
          begin
               Macro.Restart()
          end
 end
 


btw, my txt can contain 0-20 words, its just restarts as you see, if it wont find good value to write :)

so its done :D

_________________
Full time IT student/worker - BE showed me the way, so may the code be with you all!
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:33 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
saintsant wrote:
oh i see, now it should take 1st line
Code:
...


btw, my txt can contain 0-20 words, its just restarts as you see, if it wont find good value to write :)

so its done :D


Great :)

Shouldn't ever not find a good value though, unless of cause the document does not contain 20 lines.

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:41 am 
Lifetime VIP Contributor
Lifetime VIP Contributor
User avatar



Joined: Sat Apr 24, 2010 12:51 pm
Posts: 355
Location: Tallinn
Been thanked: 18 time(s)
Has thanked: 1 time(s)
Contribution Points: 4647
theres 1 thing that could make more

to change this:Variable.Set random number("randomnumb", "1", "{numb of lines}" so the restart would't be nessecary (since if you have 2-3 names there, and random is 0-100 it takes quite lot time to random 1-2 or 3)

goin to BE and tryin to see if i find a solution

_________________
Full time IT student/worker - BE showed me the way, so may the code be with you all!
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 8:49 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
saintsant wrote:
theres 1 thing that could make more

to change this:Variable.Set random number("randomnumb", "1", "{numb of lines}" so the restart would't be nessecary (since if you have 2-3 names there, and random is 0-100 it takes quite lot time to random 1-2 or 3)

goin to BE and tryin to see if i find a solution


Yea, and there is no way to get the count for number of lines from a file currently, (apart from just iterating through em...

However, I have added it to my Todo list.

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 9:08 am 
Lifetime VIP Contributor
Lifetime VIP Contributor
User avatar



Joined: Sat Apr 24, 2010 12:51 pm
Posts: 355
Location: Tallinn
Been thanked: 18 time(s)
Has thanked: 1 time(s)
Contribution Points: 4647
Code:
 begin
     Variable.Set("X", "0")
     File.Read first line("C:/macro/input.txt", "input")
     If  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     if  Variable.Is not empty("input")
          begin
               File.Read next line("C:/macro/input.txt", "input")
               Variable.Increment (Math)("X")
          end
     If  Variable.Is empty("input")
          begin
               Variable.Set random number("randomnumb", "1", "{X}")
               if  Variable.Exists("randomnumb")
                    Begin
                         Variable.Evaluate (Text)("{randomnumb} and {X}", "result")
                         Window.Display Message Box("{result}", "yes")
                    end
          end
 end


well this works :D up to 10 words ill try to put it in loop, tho this insane :) (display box just to check if it worked) tho this formum could use spoils ;)

_________________
Full time IT student/worker - BE showed me the way, so may the code be with you all!
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Random word picker from the list
Thanked: 0 time(s)  Unread post Posted: Tue May 25, 2010 9:32 am 
Partner / Developer
Partner / Developer
User avatar



Joined: Mon Jan 18, 2010 11:51 am
Posts: 4525
Been thanked: 1346 time(s)
Has thanked: 133 time(s)
Contribution Points: 33209
;)
Code:
 begin
     Variable.Set("X", "0")
     File.Read first line("C:/macro/input.txt", "input")
 end
 begin loop()
     File.Read next line("C:/macro/input.txt", "input")
     if  Variable.Is empty("input")
          begin
               Macro.Break from loop()
          end
     Variable.Increment (Math)("X")
 end
 begin
     Variable.Evaluate (Text)("The document contains {X} lines", "output")
     Window.Display Message Box("{output}", "yes")
 end
 

_________________
Blue Eye - Developer / Moderator
Code:
Gigus


Please read the rules about contribution points - click here

Do you know everything about BE, the forum, licenses and contribution points?
Please take a minute to read this introduction & guidelines.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page 1, 2, 3  Next

All times are UTC


You cannot post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group