topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 2:41 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - dreats [ switch to compact view ]

Pages: [1]
1
Precisely.

It is complete and working better than expected.

A BIG THANK YOU GOES TO JGPAIVA!

I'll be donating to the site later this week. What a great community.

2
Hey it works. Better than I could ask for actually... ignoring lines without the syntax and everything.

I made a few little changes to the GUI to make it more windows-like.

Just one thing, could you add a little tag before the text, saying the real percentage, in 100% base denominator? So the text would read "[50%] foobar" instead of just "foobar"...

Thank you for this.

#NoTrayIcon

FileToRead = Todo.txt ;replace "FILE.txt" by the name of the file to read
Sum = 0
AutoTrim,Off
Loop, Read, %FileToRead%,,
{
  Flag=false
  Loop, parse, A_LoopReadLine, %A_Tab%
  {
    If Flag=true
      continue
    Sum +=%A_LoopField%
    Flag=true
  }
}
Random, Number, 1, Sum
Sum = 0
Line = 0
Loop, Read, %FileToRead%,,
{
  Line+=1
  Flag=false
  Loop, parse, A_LoopReadLine, %A_Tab%
  {
    If Flag=true
      If Sum>=%Number%
      {
Message=%A_LoopField%
        GoSub, Found
        Return
      }     
    Sum +=%A_LoopField%
    Probability=%A_LoopField% 
    Flag=true

  }
}
return
 
Found:
  Gui, Add, Picture, x11 y11 Icon5, user32.dll
  Gui, Add, Button, gSave x78 y66 w75 h23 +default,&OK
  Gui, Add, Button, gRetry x158 y66 w75 h23,&Retry
  Gui, Add, Button, gGuiClose x239 y66 w75 h23 , &Cancel
  Gui, Add, Edit, vNewProbability x10 y58 w32 h20 Limit4,%Probability%
  Gui, Font,  s12 w700, Verdana
  Gui, Add, Text, x61 y10 w327 h38,%Message%
  Gui, Show, xCenter yCenter h101 w395, RandomLine
Return

GuiClose:
ExitApp

Save:
  Gui,Submit
  FileRead,CompleteFile,%FileToRead%
  StringReplace,CompleteFileModified,CompleteFile,``n,`n,ReplaceAll
  StringReplace,CompleteFile,CompleteFileModified,%probability%%A_Tab%%message%,%NewProbability%%A_Tab%%message%
  FileDelete,%FileToRead%
  FileAppend,%CompleteFile%,%FileToRead%
  ExitApp

Retry:
Reload

3
Great, thanks for your quick response!

As long as we're already doing this, and I'll be donating to either the site or the coder, why not kick it up a notch? :)

I was thinking maybe adding an editable textfield inside the msgbox or window where this random line would appear. to make it easier to change the probability of it appearing next time...

Let me know if you have any suggestions. i by the way would be using it as a nifty todo list utility, helping me decide what to do next.

EDIT: Yeah and language doesn't matter. exe, ahk, vbs, just let it work on windows.

4
This may seem useless to most, so if it's too difficult to make I am willing to donate a few coins, if it is allowed, to spur some motivation.

I need a script that will work something like this: once executed it will output a random line from a specified text file.

Except, there would be a little probability involved.

Each line in this text file is specially formatted in a particular syntax: "<NUMBER>, <TEXT>". The number represents the probability of the text to display in cumulative percentage.

Take for example this txt file with these two lines in it:

10, helloworld
10, foobar

50/50 chance either would be displayed. In contrast, if it was:

518572, helloworld
10, foobar

99.9% you'll see "helloworld".

Let me know how feasible it is. I will donate to either the site or the coder. 15-20$ depending on difficulty sounds ok? I really don't know.

Pages: [1]