Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Randomize between different texts
Hi everyone,

I need some help creating a macro.

Everytime I hit the hotkey, I want it to go through a list of lets say 20 different line of text and RANDOMLY or in ORDER pick one of them to paste out! For example:


So it would randomly or in order pick one of these and paste or type out once I hit the hotkey.

Would really appreciate it if anyone could help me with this! Smile

Thanks in advance
See below. I'm sure it can be done much smaller with an array, but here is a simple way to achieve what you are asking.

Macro Random Message
Select All      Help
str messageText = ""
int i = 0

i=RandomInt(1 20)
if (i = 1)
,messageText = "A"
if (i = 2)
,messageText = "B"
if (i = 3)
,messageText = "C"
if (i = 4)
,messageText = "D"
if (i = 5)
,messageText = "E"
if (i = 6)
,messageText = "F"
if (i = 7)
,messageText = "G"
if (i = 8)
,messageText = "H"
if (i = 9)
,messageText = "I"
if (i = 10)
,messageText = "J"
if (i = 11)
,messageText = "K"
if (i = 12)
,messageText = "L"
if (i = 13)
,messageText = "M"
if (i = 14)
,messageText = "N"
if (i = 15)
,messageText = "O"
if (i = 16)
,messageText = "P"
if (i = 17)
,messageText = "Q"
if (i = 18)
,messageText = "R"
if (i = 19)
,messageText = "S"
if (i = 20)
,messageText = "T"
out messageText
this might be closer to what you are trying to do.

Function randomize_or_choose_text_
Trigger Sz     Help - how to add the trigger to the macro
Select All      Help
ARRAY(str) messageText="Random[]a[]b[]c[]d[]e[]f[]g[]h[]i[]j[]k[]l[]m[]n[]o[]p[]q[]r[]s[]t[]u[]v[]w[]x[]y[]z"
;;the above array is just for this demo. Change to whatever text you would like. each line of
;;text needs to have [] after it except last item
;; example ARRAY(str) messageText="Random[]Hi[]Hello[]Bye[]Goodbye[]Okay[]OK"
str result=messageText;;convert array to a string so we can display it in the ListDialog
int i=ListDialog(result);
sel i
,case 0
,case 1;;Random selected
,int ii=RandomInt(2 27);;set number range from 2-27 since 0 means cancel button clicked and 1 is for random
,out messageText[ii-1];;send to qm output window random item
,case else;; any other selected item
,out messageText[i-1];;send to qm output window selected item
Hi, thanks for the help guys but none of these helped me unfortunately (maybe because im stupid)

The first one gave nothing in output, did not paste out anything anywhere upon press

The second one brings up a dialog I dont need, I just need it to paste or write out a random message from a list of messages.
Macro Macro2948
Select All      Help
str messages=

ARRAY(str) a=messages
paste a[RandomInt(0 a.len-1)]

;area for testing

Forum Jump:

Users browsing this thread: 1 Guest(s)