rcmaehl Posted April 20, 2012 Share Posted April 20, 2012 (edited) Note: math is zero-based as it's on a grid 1. I have a 16x16 grid of squares (256 total) 2. Within each square are smaller squares (256 total) that are also arranged 16x16 3. I need to two numbers and covert them to determine which large square and which small square should be colored 4. I need a formula that would do this: Data: (Num1.Num2) = (x,y) 0.0 = 0,0 0.1 = 1,0 0.2 = 2,0 ... 0.16 = 0,1 0.17 = 1,1 0.18 = 2,1 ... 16.0 = 0,16 ... 16.16 = 0,17 16.17 = 1,17 16.18 = 2,17 ... 255.255 = 255,255 Edited April 24, 2012 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
jchd Posted April 20, 2012 Share Posted April 20, 2012 You'll need to work with integers and Mod(), as in $value = Mod($input, 16) Your examples are wrong AFAICT. Are you really going to try working with 16.17 (floating point values)? If so, you setup yourself for surprises. 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 hereRegExp tutorial: enough to get startedPCRE 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) Link to comment Share on other sites More sharing options...
rcmaehl Posted April 20, 2012 Author Share Posted April 20, 2012 The 2 numbers are part of an IP address. The . is the separator of the 2 numbers. I should of specified that. My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
BrewManNH Posted April 20, 2012 Share Posted April 20, 2012 As stated in your other thread, there are no valid IP addresses that start with "0.x" and there are also no valid IP addresses that start with anything above "223.x" so you wouldn't need to include those in your grid. There are also a lot of other IP addresses that aren't valid that don't need to be included, because you'll never see them. If you are doing this for Internet IP addresses, and not LAN IP addresses, you can eliminate all of the private IP address ranges from the list as well, because if you ever saw one of them in an internet address it's an error. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
rcmaehl Posted April 20, 2012 Author Share Posted April 20, 2012 (edited) As stated in your other thread, there are no valid IP addresses that start with "0.x" and there are also no valid IP addresses that start with anything above "223.x" so you wouldn't need to include those in your grid. There are also a lot of other IP addresses that aren't valid that don't need to be included, because you'll never see them. If you are doing this for Internet IP addresses, and not LAN IP addresses, you can eliminate all of the private IP address ranges from the list as well, because if you ever saw one of them in an internet address it's an error.I'll add that after the formula for this. It would most likely be easier. Edited April 20, 2012 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
rcmaehl Posted April 23, 2012 Author Share Posted April 23, 2012 (edited) It has been more than 24 hours. I still need help. P.S. This is a "bump" Edited April 23, 2012 by rcmaehl My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
water Posted April 23, 2012 Share Posted April 23, 2012 What have you coded so far? Can you post your script? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
JohnQSmith Posted April 23, 2012 Share Posted April 23, 2012 Here ya go. Next time I'd like to see a little code from you first. For $i = 0 To 255 For $j = 0 To 255 $x = Mod($j, 16) $y = Floor($j / 16) + Mod($i * 16, 256) ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF) Next Next Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". Link to comment Share on other sites More sharing options...
Mat Posted April 23, 2012 Share Posted April 23, 2012 Hah. This thread showed up as the latest topic in General help and support as "I Need Mat..." AutoIt Project Listing Link to comment Share on other sites More sharing options...
rcmaehl Posted April 23, 2012 Author Share Posted April 23, 2012 Here ya go. Next time I'd like to see a little code from you first. For $i = 0 To 255 For $j = 0 To 255 $x = Mod($j, 16) $y = Floor($j / 16) + Mod($i * 16, 256) ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF) Next Next I actually was just about to upload it. I just noticed that your math is wrong, but I think I understand what I have to do. Thanks Hah. This thread showed up as the latest topic in General help and support as "I Need Mat..." Heh. My UDFs are generally for me. If they aren't updated for a while, it means I'm not using them myself. As soon as I start using them again, they'll get updated.My Projects WhyNotWin11Cisco Finesse, Github, IRC UDF, WindowEx UDF Link to comment Share on other sites More sharing options...
JohnQSmith Posted April 23, 2012 Share Posted April 23, 2012 I just noticed that your math is wrong I hate it when that happens. Try this one. For $i = 0 To 255 For $j = 0 To 255 $x = Mod(Mod($j, 16) + (Mod($i, 256) * 16), 256) $y = Floor($j / 16) + 16 * Floor($i / 16) ConsoleWrite($i & "." & $j & " = " & $x & "," & $y & @CRLF) Next Next Thanks Glad to help. Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes". 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