0x90h Posted December 28, 2007 Share Posted December 28, 2007 once again i have found myself in troubles trying to split every given number into array of multiply of number 5 and the rest. for example, given numbers are: 6,10,18,22 i want to split each of these numbers into array like this: 6 = [5, 1] 10 = [5, 5] 18 = [5, 5, 5, 3] 22 = [5, 5, 5, 5, 2] would you be so nice and give me a hand on this? Link to comment Share on other sites More sharing options...
martin Posted December 28, 2007 Share Posted December 28, 2007 once again i have found myself in troubles trying to split every given number into array of multiply of number 5 and the rest. for example, given numbers are: 6,10,18,22 i want to split each of these numbers into array like this: 6 = [5, 1] 10 = [5, 5] 18 = [5, 5, 5, 3] 22 = [5, 5, 5, 5, 2] would you be so nice and give me a hand on this? Maybe this (not tried) $NumElements = Int($Number/5) + 1;add one for remainder even if it's zero $remainder = Mod($number,5) Dim $array[$NumElements] For $n = 0 to $NumElements - 2 $array[$n] = 5 next $array[$NumElements - 1] = $Remainder Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Jex Posted December 28, 2007 Share Posted December 28, 2007 (edited) Global $Split[7], $Data $Split[1] = Split(5, 5) $Split[2] = Split(10, 5) $Split[3] = Split(18, 5) $Split[4] = Split(22, 5) $Split[5] = Split(2, 8) $Split[6] = Split(76, 8) For $i = 1 To 6 $Data &= $Split[$i] & @CRLF Next MsgBox("", "", $Data) Func Split($Number, $Limit) $Test = "" While $Number > $Limit $Number -= $Limit $Test &= $Limit & ", " WEnd $Test &= $Number Return $Test EndFunc ;==>Split That func not create array but will be useful for you i think. Edited December 28, 2007 by Jex My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
martin Posted December 28, 2007 Share Posted December 28, 2007 $Count = 0 $Test = "" $Number = 28 Do $Number -= 5 $Count += 1 Until $Number < 5 For $i = 1 To $Count $Test &= "5, " Next $Test &= $Number MsgBox("", "", $Test) That not give array but give like that : If $Number = 28 Then $Test = "5, 5, 5, 5, 5, 3" Not quite. If you start with a number which is less than 5 it will be wrong $number=28 while $number >= 5 $number -= 5 $Test &= "5," wend $test &= $number Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Jex Posted December 28, 2007 Share Posted December 28, 2007 Not quite. If you start with a number which is less than 5 it will be wrong $number=28 while $number >= 5 $number -= 5 $Test &= "5," wend $test &= $number Ahh sorry i'm didn't noticed will be wrong if number less than 5 I'm fixed now thanks My scripts : Immediate Window , My Web Browser , Travian , Text Effect , Characters & Words per minute or second , Image Editor (ImageMagick) , Matrix style background effect ( Screensaver ) , Mail Sender , Protectlinks decoder and Rapidshare links checker , Fonts Fetcher , Region determine , Compare pictures , Gradient color box , Mouse Coordinates, Colors, Pixel Search things , Encrypt/Decrypt and embeding file in jpeg thing , Hard disk space monitor , Reflex game , Multiplayer Tic Tac Toe , WLM ( MSN ) personal message changer Link to comment Share on other sites More sharing options...
0x90h Posted December 28, 2007 Author Share Posted December 28, 2007 thanks for helping me on this issue best wishes, 0x90 nop Link to comment Share on other sites More sharing options...
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