Queener Posted April 16, 2013 Share Posted April 16, 2013 (edited) How do you write this code to an array. I have 3675 to 3682 and another number which isn't in the same range (25834). Func IsTest($id) For $i = 3675 To 3682 If $id = Hex($i, 8) Then Return True Else Return False EndIf EndFunc I was thinking about Func IsTest($id) For $i = 3675 To 3682 & 25834 If $id = Hex($i, 8) Then Return True Else Return False EndIf EndFunc or Func IsTest($id) For $i = 3675 To 3682 If $id = Hex($i, 8) Then Return True Else Return False EndIf Next For $l = 25834 If $id = Hex($l, 8) Then Return True Else Return False EndIf EndFunc But these test doesn't work. Return as array incorrect prefix. Edited April 16, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
kylomas Posted April 16, 2013 Share Posted April 16, 2013 (edited) Close your for...to loop with a "next" for starters... You want to write the return value to an array outside of the function? edit: question Edited April 16, 2013 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted April 16, 2013 Moderators Share Posted April 16, 2013 Be much more specific. I have no idea what you're asking. What is id, what does 25834 have to do with anything, are you comparing a string value on purpose, is the "True/False" what you want in the array, how do you want to match it to 3675/3682, etc. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Queener Posted April 16, 2013 Author Share Posted April 16, 2013 Long story make it short; I have another list that this file will be pulling. [item] $id[3675]= '000A' $id[3676]= '000B' etc... $id[25834]='0300' If IsTest = i then show else don't show. If I don't include 25834 then the code is already working fine, but like to know how to add this number to it. I wouldn't want to do 3675 To 25834 because all other code above 3682 represent something else other than color. Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
tlman12 Posted April 16, 2013 Share Posted April 16, 2013 Be much more specific. I have no idea what you're asking. What is id, what does 25834 have to do with anything, are you comparing a string value on purpose, is the "True/False" what you want in the array, how do you want to match it to 3675/3682, etc. What about Func IsTest($id) If $id = 25834 Then Return True Else For $i = 3675 To 3682 If $id = Hex($i, 8) Then Return True Else Return False EndIf Next EndIf EndFunc ;==>IsTest Link to comment Share on other sites More sharing options...
Queener Posted April 16, 2013 Author Share Posted April 16, 2013 (edited) autoit is so picky about how you actually format it... working on the script; if it works; I'll ping you guys. Thank EDIT: Error: "Next" statement with no matching "For" statement. Edited April 16, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
kylomas Posted April 16, 2013 Share Posted April 16, 2013 (edited) tlman12, Your code iterates the loop once and returns. It should probably look more like this (untested) Func IsTest($id) If $id = 25834 Then Return True For $i = 3675 To 3682 If $id = Hex($i, 8) Then Return True Next return false ; this needs to be outside of for loop EndFunc ;==>IsTest @asianqueen, It is difficult to understand what you are asking. The following example will update an array with true or false. #include <array.au3> local $aRET[1] $aRET[ubound($aRET) - 1] = IsTest(hex(3677)) ; set last element of array to value returned from function redim $aRET[ubound($aRET) + 1] ; increase array (presumably you are going to loop on this _arraydisplay($aRET) ; display array Func IsTest($id) For $i = 3675 To 3682 If $id = Hex($i) Then Return True Next Return False ; <-- this need to be outside of the for loop EndFunc autoit is so picky about how you actually format it... As opposed to what? kylomas Edited April 16, 2013 by kylomas Xandy 1 Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
tlman12 Posted April 16, 2013 Share Posted April 16, 2013 tlman12,Your code iterates the loop once and returns. It should probably look more like this (untested)ha your right, didn't even notice that. i only copied what he had and added the if statement. didn't try to run it Link to comment Share on other sites More sharing options...
Queener Posted April 16, 2013 Author Share Posted April 16, 2013 (edited) As opposed to what? kylomas You can't type for example where all can't be aligh left: Call function If statement Return True Else False It has to be in the correct format with tabs and spaces. By the way Func IsTest($id) If $id = 25834 Then Return True For $i = 3675 To 3682 If $id = Hex($i, 8) Then Return True Next return false ; this needs to be outside of for loop EndFunc ;==>IsTest does not have an endif recall. Edited April 16, 2013 by asianqueen Msgbox(0, "Hate", "Just hate it when I post a question and find my own answer after a couple tries. But if I don't post the question, I can't seem to resolve it at all.") Link to comment Share on other sites More sharing options...
kylomas Posted April 16, 2013 Share Posted April 16, 2013 asianqueen,It has to be in the correct format with tabs and spaces.Not true...does not have an endif recall. Does not need one...Let me suggest two things: 1 - Spend some time reading the help file 2 - When posting for advice, think through what you are asking and see it from a readers perspective. Sometime we get too close to the code to see "the forest for the trees", so to speak.Good Luck,kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
guinness Posted April 16, 2013 Share Posted April 16, 2013 Returning in a loop is back coding practice. It's better to exit the loop and use a return variable. 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...
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