Sign in to follow this  
Followers 0
zeffy

Help make more elegant array declaration

5 posts in this topic

#1 ·  Posted (edited)

Hi, I'm trying to build an array to use with _GDIPlus_GraphicsDrawPolygon(), and I have all of the array values done, but I want a more elegant way of doing it, like shown here, but I don't really know how to do it right. This is what I have so far:

Local $aPoints[11][2]

$aPoints[0][0] = 10
$aPoints[1][0] = 0
$aPoints[1][1] = 11
$aPoints[2][0] = 5
$aPoints[2][1] = 16
$aPoints[3][0] = 5
$aPoints[3][1] = 13
$aPoints[4][0] = 14
$aPoints[4][1] = 13
$aPoints[5][0] = 14
$aPoints[5][1] = 5
$aPoints[6][0] = 10
$aPoints[6][1] = 5
$aPoints[7][0] = 10
$aPoints[7][1] = 9
$aPoints[8][0] = 5
$aPoints[8][1] = 9
$aPoints[9][0] = 5
$aPoints[9][1] = 6
$aPoints[10][0] = 0
$aPoints[10][1] = 11

_GDIPlus_GraphicsDrawPolygon ($hGraphic, $aPoints)
Edited by zeffy

Share this post


Link to post
Share on other sites



This looks like you do not understand what you are trying to do. You are declaring arrays on top of arrays.


[font="Comic Sans MS"]My code does not have bugs! It just develops random features.[/font]My Projects[list][*]Live Streaming (Not my project, but my edited version)[right]AutoIt Wrappers![/right][/list]Pure randomness[list][*]Small Minds.......................................................................................................[size="1"]Simple progress bar that changes direction at either sides.[/size][*]ChristmasIt AutoIt Christmas Theme..........................................................[size="1"]I WAS BOOOORED![/size][*]DriveToy..............................................................................................................[size="1"]Simple joke script. Trick your friends into thinking their computer drive is haywire![/size][/list]In Development[list][*]Your Background Task Organiser[*]AInstall Second Generation[/list]BEFORE POSTING ON THE FORUMS, TRY THIS:
%programfiles%/AutoIt3/autoit3.chm

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

You are declaring arrays on top of arrays.

No, zeffy is not "declaring arrays on top of arrays".

zeffy:

When the data you need, or are using, gets bigger than what you care to maintain as a hard-coded array setup+fill.

You should start looking at dropping that data into a external data file, and code you code to read and process that file as your array data input source.

Alt: Local $aPoints[11][2] = [[10,''],[0,11],[5,16],[5,13],[14,13],[14,5],[10,5],[10,9],[5,9],[5,6],[0,11]]

(done with Array_GetDefinition)

Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks MvGulik! :x

Edited by zeffy

Share this post


Link to post
Share on other sites

And for the future in case you have a large array that spans the whole screen, try to use "_" underscore separator to move to the next line. You can see the use of this in some of the examples in my sig!

Local $aPoints[11][2] = [[10, ''],[0, 11],[5, 16],[5, 13],[14, 13], _
        [14, 5],[10, 5],[10, 9],[5, 9],[5, 6], _
        [0, 11]]

_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_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 parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0