Champak Posted December 1, 2014 Posted December 1, 2014 If I'm in a for...next loop that goes up to 50 Is it possible to make it do something specific every 5th loop without doing if "$i=x or" for all the 5th integers?
Moderators Melba23 Posted December 1, 2014 Moderators Posted December 1, 2014 Champak,Use the Mod function as a filter: For $i = 1 To 50 If Mod($i, 5) = 0 Then ConsoleWrite($i & @CRLF) NextThat will fire on 5, 10, 15, etc. 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
iamtheky Posted December 1, 2014 Posted December 1, 2014 (edited) That only fires 'every 5th loop' if you start at 1 (unless of course you account for the starting number and subtract/add that to $i in the mod function, which still seems the long way around). How is evaluating the variable then doing divsion, a better solution then just counting to 5 yourself inside the loop (or using step)? Not being coy, just really want to know why this method is being sought in case it is useful. Edited December 1, 2014 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__)
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