Padol Posted January 22, 2016 Share Posted January 22, 2016 A fully detailed "What to know" for Maps101 can be found here I'm here to explain my opinion over maps, i like it so much, give to autoit someting of object orientet... I want to talk of the use i got from maps, specificlly Multi-Dimensional Maps Maps101 usage Global $mObj[] ; can be stored Global here, local inside a function or somiething like that $mObj.instance=1 ;the mObjct . instance was declared to be 1 or true msgbox(0,"",$mObj.instance) really easy, not? now something more hard i was impressed to the semplicity of maps give me to realize an artificial intelligence, a sort of little game of life (not konoweys) The maps can give you a multi-Dimensional tipe of array it's noting that $array[][] couldn't do but let me explain how much it's easyer thats a really simple algorithm that improve autoit object oriented like programming in this example i use some java syntax like to obtain someting like string.len or character.getPos.x else character.getPos.y expandcollapse popup; i have a gridMap ;in one or more slot of the gridMap ;i have an individue, an essence, an object Global $aGridMap[10][10] ; declaring the grid map ; the gridMap goes from a range value of 0~9 ;now i want to instance some individue, essence or object ;on a grid of 10 x 10 i can declare 100 dinstincte object ;but i need to store it first in a multidimensional-Array Global $instance = 2 ;number of object that i want to initialize Global $aWorldArray[$instance][4] $aWorldArray[0][0] = 2 ;at this point i select a pos for the obj in the grid This is the x value $aWorldArray[0][1] = 4 ;this is the y vaue $aWorldArray[0][2] = 0x00FF00 ;this is the color of the element $aWorldArray[0][3] = "fruit" ;this is the type of the element $aWorldArray[1][0] = 5 ;same as up $aWorldArray[1][1] = 3 $aWorldArray[1][2] = 0xFF0000 $aWorldArray[1][3] = "animal" ;this dosen't look great, i really dosn't apprecciate this approach ;now i want to realize a sort of structure where i can modify the parameters how i want. ;_arrayToMaps transform the multidimensional array from world to a specified individue ;$array is the $aWorldArray, ;~ the $n is the instance, the element we want to grab Func _ArrayToMaps(ByRef $array, $n = 0);the byref grab the entire array Local $mIndividue[] ;preparing for maps Local $mPos[] ;creating the multidimension map for .x .y pos $mPos.x = $array[$n][0] $mPos.y = $array[$n][1] $mIndividue.getPos = $mPos ; with this trick someting magic appens, the .x .y was attached to the getPos node root $mIndividue.n = $n ;remember his own position into the world obj list $mIndividue.type = $array[$n][3] $mIndividue.color = $array[$n][2] ;we have now a single Individue from an array wolrd of objct ;but we want do more hazard thing :P let's destroy the compiler, (my brain maybe) ;we want the $mIndividue Maps store in its own node an entire multidimensional array $mIndividue.array = 0 ;a blank array node to the individue Local $aMultiDim[2][2] ; a structure that contain two names at [0][0] and [0][1] and two surname at [1][0] and [1][1] $aMultiDim[0][0] = "Mario" $aMultiDim[0][0] = "Mary" $aMultiDim[1][0] = "noodles" $aMultiDim[1][1] = "nuggets" ;let's add the multy dim array to $mIndividue.array $mIndividue.array = $aMultiDim ;now you have a complete $mIndividue that contain for example the name... ;How to use $mIndividue.array[1][0] to get "noodles" as a string! Absolutely crazy :D i've never seen or use something like that ;i really dosn't think that a map's really need a multidim array but that make the things more easyer ;i want now to operate with the individue structure, then return the map Return $mIndividue EndFunc ;==>_ArrayToMaps ;i make a function that operate on an individue obj type Func _changeSometing(ByRef $mIndividue) ;i want to move my object to an other position then $mIndividue.getPos.x = 6 $mIndividue.getPos.y = 3 ;i want to change the color then $mIndividue.color = 0x0000FF ;for blue, an hex RGB value, 0x 00 00 ff, on int it was R000 G000 B255 ;and i want also read some data from the array node Local $string = '' ;make a blanck string that contain the array info For $i = 0 To 1 For $u = 0 To 1 $string &= $mIndividue.array[$i][$u] & @CRLF ;usage of multidim array into the array map Next Next ;then output the array MsgBox(0, "lets Read the name!", $string) ;$string is only the concatenation of $mIndividue.array Return $mIndividue ;return the entire map! EndFunc ;==>_changeSometing ;i make now a function that rewrite back the individual information to a multidimensional array World Func _MapsToArray(ByRef $mIndividue) ;this time we don't need the position of the object in the array, because it was store in individue.n Local $n $n = $mIndividue.n ;get back it's own stacks $aWorldArray[$n][0] = $mIndividue.getPos.x ;at this point i select a pos for the obj in the grid This is the x value $aWorldArray[$n][1] = $mIndividue.getPos.y ;this is the y value $aWorldArray[$n][2] = $mIndividue.color $aWorldArray[$n][3] = $mIndividue.type ;useless because the $mIndividue.type wasn't changed but that eventually restore the value onto the world array obj ;~ $aWorldArray is stored globally then i don't need to return a parameters EndFunc ;==>_MapsToArray Func Main();i like to write a main function like c ;we have the entire project now let's concatenate ;~ i want my world array of obj goes to an single individue map then $aWorld = $aWorldArray ; i get the array parameter $mSingleObjectFromWorld = _ArrayToMaps($aWorld) ;given array tipe, return maps type MsgBox(0, "old Pos", $mSingleObjectFromWorld.getPos.x & @CRLF & $mSingleObjectFromWorld.getPos.y );read the pos $mSingleObjectFromWorld=_changeSometing($mSingleObjectFromWorld);lets the function modify someting MsgBox(0, "new Pos", _ $mSingleObjectFromWorld.getPos.x & @CRLF _ & $mSingleObjectFromWorld.getPos.y ) ;see what's changed ;now restore back the data to a single multidimensional array from each individue _MapsToArray($mSingleObjectFromWorld) ; thats restore the $mIndividue changes from single obj to the world multidim array of elements ;$mSingleObjectFromWorld know is index in the array, because it was stored as $mSingleObjectFromWorld.n where n is the array index EndFunc ;==>_Main Call("Main") easy explanation of possible uses one examples that took me into java syntax Func _simpleString($string);transofrm a string to someting like Java Local $mapString[] $mapString.string = $string $mapString.len = StringLen($string) Local $chAsci $chAsci = StringToASCIIArray($string) For $i = 0 To UBound($chAsci) - 1 $chAsci[$i] = Chr($chAsci[$i]) Next $mapString.char = $chAsci Return $mapString EndFunc ;==>_simpleString ;~-----the script starts here---- $strin = 'ciao' $mString = _simpleString($strin) MsgBox(0,"the string",$mString.string) MsgBox(0, "the lenght of the string", $mString.len) MsgBox(0, "the first character of the string", $mString.char[0]) MsgBox(0, "the last character of the string", $mString.char[$mString.len - 1]) isn't this like a well organizated structure?! i hope this was helpfull Kiss! Xandy and TheDcoder 2 Link to comment Share on other sites More sharing options...
TheDcoder Posted January 29, 2016 Share Posted January 29, 2016 Wow, Nice demonstration of using Maps ... Although, I don't understand OOP P.S I also made a Experimental Maps UDF which contains a function similar to _ArrayToMaps EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
guinness Posted January 29, 2016 Share Posted January 29, 2016 Misuse of the language and misunderstanding of OOP. #myopinion UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Guest Posted January 31, 2016 Share Posted January 31, 2016 Thank you.I just I needed see your example to be convinced.I think it's different from what I've seen before. Is this feature is included in the latest releas(not beta) ? Link to comment Share on other sites More sharing options...
TheDcoder Posted January 31, 2016 Share Posted January 31, 2016 @gil900 Nope, only beta versions EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion Link to comment Share on other sites More sharing options...
Guest Posted January 31, 2016 Share Posted January 31, 2016 OK, Do you think that will be drastic changes (big script breaking changes) in this feature when it will be relesed in non-beta ? Link to comment Share on other sites More sharing options...
TheDcoder Posted February 1, 2016 Share Posted February 1, 2016 @gil900 Who knows? ¯\_(ツ)_/¯, They might even remove it... or change the syntax. EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time) DcodingTheWeb Forum - Follow for updates and Join for discussion 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