Send Random Line from a Text File

From Gwen Morse's Wiki
Jump to: navigation, search

;;; Send random line from a file

; Someone wrote a couple of macros which would send random messages to a particular world.
; Usage is: random_file_line <file>
; You'd get a random line from that file returned.
; Apology to the author of the macro for not acknowledging you but I don't
; know who thou art. (posted to the TF mailing list by: CD <cyberd at>) 

/def -i random_file_line = \
    /let selection= %; \
    /let lines=0 %; \
    /quote -S /random_line_ '%* %; \
    /_echo %{selection} 

/def -i -q random_line_ = \
    /test rand(++lines) | (selection := {*})
/def -p3 -F -w"spark" -h"CONNECT" random_file_run = \
    /quote `/random_file_line file.txt