Arclite86

shuffle number from 1 to 5

26 posts in this topic

I have a script that has 5 inputs

these inputs are filled with number from 1 to 5

so:

input1 = 1

input2 = 2

input3 = 3 

input4 = 4

input3 = 5 

but I want it to shuffle the numbers like:

input1 = 4

input2 = 1

input3 = 5

input4 = 2

input5= 3

I dont want to use the Random function because then there is a possibilty It will chose number with the same value, I need a number from 1 to 5 to be shown but in different order

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

There's a function for that:
 

_ArrayShuffle

Edit: I've been defeated. Hands John a beer.

Edited by minx

I will answer every single PM, and you are free to ask anything anytime.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try using an array with the _ArrayShuffle() function then assigning each value to an input.

:( to slow

Edited by libreau3

Share this post


Link to post
Share on other sites

I cant find the  _ArrayShuffle() function is there a file that i need to instal before? if yes than what

Share this post


Link to post
Share on other sites

You need to include the Array UDF. Use

#include <Array.au3>

BTW: Which version of AutoIt do you run?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

You need to include the Array UDF. Use

#include <Array.au3>

BTW: Which version of AutoIt do you run?

i did , but maybe its an old version could you give me a link to the latest function script

Share this post


Link to post
Share on other sites

Your best bet is always to use a current release (or beta if you want) of the complete official AutoIt distribution. You find it like all of us mere mortals, in the dedicated download section.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

I downloaded the latest beta version but still the  _ArrayShuffle() turns black and unrecognisable

this is a  screenshot

2zdzw5g.jpg

Share this post


Link to post
Share on other sites

You need to check the help file! Set the cursor on _ArrayShuffle and press F1.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

a29pox.jpg

nothing happens

Edited by Arclite86

Share this post


Link to post
Share on other sites

As you can see you run an old version of Autoit (3.3.10.2). Upgrade to the latest production version (3.3.12.0) and the problem goes away.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

aaa thank you that was it, thank you Water

Share this post


Link to post
Share on other sites

I guess you downloaded and installed the latest beta. But to run a script with a beta version you need to press Alt+F5 ind SciTE. Just pressing F5  executes the script using the installed production version.

Means: You can have a production and a beta version installed in parallel.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

sorry for asking but I just cant figure out how to get the number from a  array to an input, this is what i tried

Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]


Local $aArray = $aArray_Base
_ArrayShuffle($aArray)
_ArrayDisplay($aArray, "1D - Shuffled", Default, 16)

$aArray = 1

$readfrom = _FileReadToArray(, $aArray, 1)

GUICtrlSetData($input1,$readfrom)
Edited by Arclite86

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

You need to specify wich element in the array:

Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]


Local $aArray = $aArray_Base
_ArrayShuffle($aArray)
_ArrayDisplay($aArray, "1D - Shuffled", Default, 16)


GUICtrlSetData($input1,$aArray[0])
Edited by Geir1983

Share this post


Link to post
Share on other sites

Arclite86,

Just loop through the array like this: :)

#include <GUIConstantsEx.au3>
#include <Array.au3>

Local $aArray_Base[16] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15]
Local $aArray = $aArray_Base
_ArrayShuffle($aArray)

$hGUI = GUICreate("Test", 500, 500)

$cInput = GUICtrlCreateInput("", 10, 10, 200, 40)
GUICtrlSetFont($cInput, 24)

GUISetState()

For $i = 0 To 15
    GUICtrlSetData($cInput, $aArray[$i])
    Sleep(500)
Next

Exit
M23

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

i dont understand this one:

it misses one number:

#Region ### START Koda GUI section ### Form=
$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)

$Input1 = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Input2 = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Input3 = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Input4 = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Input5 = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Input6 = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

   

Local $aArray_Base[6] = [ 1, 2, 3, 4, 5, 6]
Local $aArray = $aArray_Base
_ArrayShuffle($aArray)







GUISetState()

For $i = 1 To 1
    GUICtrlSetData($Input1, $aArray[$i])
sleep(500)
Next

For $i = 2 To 2
    GUICtrlSetData($Input2, $aArray[$i])
sleep(500)
Next

For $i = 3 To 3
    GUICtrlSetData($Input3, $aArray[$i])
sleep(500)
 Next

 For $i = 4 To 4
    GUICtrlSetData($Input4, $aArray[$i])
sleep(500)
 Next

  For $i = 5 To 5
    GUICtrlSetData($Input5, $aArray[$i])
sleep(500)
 Next

  For $i = 6 To 6
    GUICtrlSetData($Input6, $aArray[$i])
    sleep(500)
 Next

   For $i = 7 To 7
    GUICtrlSetData($Input6, $aArray[$i])
    sleep(500)
 Next
Edited by Arclite86

Share this post


Link to post
Share on other sites

Much easier if you store your input ids into an array

#Include <Array.au3>

Local $inputs[6]

$Form1_1 = GUICreate("Form1", 477, 291, 293, 182)
$Inputs[0] = GUICtrlCreateInput("Input1", 0, 64, 41, 21)
$Inputs[1] = GUICtrlCreateInput("Input2", 0, 88, 41, 21)
$Inputs[2] = GUICtrlCreateInput("Input3", 0, 112, 41, 21)
$Inputs[3] = GUICtrlCreateInput("Input4", 0, 136, 41, 21)
$Inputs[4] = GUICtrlCreateInput("Input5", 0, 160, 41, 21)
$Inputs[5] = GUICtrlCreateInput("Input6", 0, 184, 41, 21)

Local $aArray[6] = [ 1, 2, 3, 4, 5, 6]
_ArrayShuffle($aArray)

For $i = 0 To 5
    GUICtrlSetData($Inputs[$i], $aArray[$i])
Next
GUISetState()

While 1
  Sleep(10)
Wend

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now