kalya Posted September 18, 2014 Posted September 18, 2014 (edited) Can someone tell me why I have not the same result when running this script . I mean that last posting should have 3 positions with this values . expandcollapse popup #include <GUIConstantsEx.au3> #include <Array.au3> $lista = InputBox("CLV", "greater than 9","10"," M3") if $lista < 10 Then SplashTextOn(""," error ",300, 130, -1, -1, 4, "", 15) Sleep(3000) SplashOff() Else $proc = InputBox("%", "# ________________", "70", " M2") $procent = Round($lista*$proc/100) $pr=100-$procent Local $aArray[$lista+1] For $i = 0 To $lista-1 $aArray[$i]= $i Next _ArrayDelete($aArray, 0) For $j = 1 To $procent $ran=Random(0,UBound($aArray),1) _ArrayDelete($aArray,$ran) Next MsgBox($MB_SYSTEMMODAL, "**********", _ArrayToString($aArray, ", ")) EndIf Edited September 18, 2014 by Melba23 Added code tags
Moderators Melba23 Posted September 18, 2014 Moderators Posted September 18, 2014 kalya,When deleting the items from the array you are setting the top limit too high, so sometimes the _ArrayDelete fails as you pass an index outside the array bounds. This seems to work for me - I say "seems" because it always returns an array with 3 elements, but I have no idea if they are what you want: For $j = 1 To $procent $ran = Random(0, UBound($aArray) - 1, 1) ; <<<<<<<<<<<<< Reduce the top limit to equal the highest index in the array _ArrayDelete($aArray, $ran) NextThis does seem a very complex operation - if you could explain what you are trying to achieve we might be able to suggest an easier way to get there. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kalya Posted September 18, 2014 Author Posted September 18, 2014 I must extract % from a variable list and then print it on desktop. the length of list must be variable and the % also
Moderators Melba23 Posted September 18, 2014 Moderators Posted September 18, 2014 kalya,That much I could guess - the question is not "what are you doing", but "what are you trying to achieve". From where do you get the "variable list? Why do you only need a certain percentage of its entries (and the code you posted always leads 3 elements so it does not meet with what you say you want)?Help us to help you - what is it all about? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kalya Posted September 18, 2014 Author Posted September 18, 2014 from a list must extract a certain items depend for % percentage. example : if the list have 100 items and percentage are 40 % randomly extract the items and in final must have 6 items i put myself the list length and the percent so it's variable
Moderators Melba23 Posted September 18, 2014 Moderators Posted September 18, 2014 kalya,As I cannot make any sense of what you are saying (how can 40% of 100 equal 6) I am bowing out - you have a solution to your original problem. M23P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
kalya Posted September 18, 2014 Author Posted September 18, 2014 kalya,As I cannot make any sense of what you are saying (how can 40% of 100 equal 6) I am bowing out - you have a solution to your original problem. :bye:M23P.S. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. my mistake, really sorry i mean 60.i'm on my phone. when i run my script usually have 3 items in the final list. but not every time so what's wrong. pls i need this script functionally
MikahS Posted September 18, 2014 Posted September 18, 2014 (edited) When I ran the script with 60 instead of the default 70 you put I got 5 items in the final MsgBox. Edited September 18, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
kalya Posted September 18, 2014 Author Posted September 18, 2014 (edited) When I ran the script with 60 instead of the default 70 you put I got 5 items in the final MsgBox. so, something it's wrong because must be only 4 items. delete function.?! i don't give up, i know for more peoples from here it's a ridiculously script Edited September 18, 2014 by kalya
MikahS Posted September 18, 2014 Posted September 18, 2014 (edited) Use a MsgBox throughout your code. Like so: ;example $proc = InputBox("%", "# ________________", "70", " M2") $procent = Round($lista*$proc/100) MsgBox(0, "", $procent) ; here <<<<<<< $pr=100-$procent This is very helpful and I see how it gave 5 values, instead of 4 Edited September 18, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
kalya Posted September 18, 2014 Author Posted September 18, 2014 Use a MsgBox throughout your code. Like so:;example $proc = InputBox("%", "# ________________", "70", " M2") $procent = Round($lista*$proc/100) MsgBox(0, "", $procent) ; here <<<<<<< $pr=100-$procent This is very helpful and I see how it gave 5 values, instead of 4 $procent it's everytime ok. i can se in MsgBox. the items from last array is not ok. Randomly is 4 or 5 more time is 3
Solution MikahS Posted September 18, 2014 Solution Posted September 18, 2014 Use a MsgBox anywhere you are not sure of something. I'm sorry, but I barely understood your statements Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now