Phaser Posted March 31, 2010 Share Posted March 31, 2010 Hi everyone Simple question (I hope) I have a fixed size [5] 1d array and am pushing and removing values to/from it, when there is a value in it I perform another function with that value but if its empty I don't, simple as that. How do I check it has something in it? Link to comment Share on other sites More sharing options...
JohnOne Posted March 31, 2010 Share Posted March 31, 2010 (edited) I would do something like this Local $array[5] = ["T",0,0,1,""] For $i = 0 To 4 If $array[$i] Then Msgbox(0,"Array", "Element " & $i & " Is used") EndIf Next Edited March 31, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
KaFu Posted March 31, 2010 Share Posted March 31, 2010 Dim $array[5] = [0,0,1,0,1] $iArrayEmpty = "" for $i = 0 to UBound($array) -1 if $array[$i] then $iArrayEmpty &= $i & "," next if not $iArrayEmpty Then MsgBox(0,"","Array is empty") Else $iArrayEmpty = Stringleft($iArrayEmpty,StringLen($iArrayEmpty)-1) MsgBox(0,"","Array contains values at position " & $iArrayEmpty) endif Dim $array[5] = [0,0,0,0,0] $iArrayEmpty = "" for $i = 0 to UBound($array) -1 if $array[$i] then $iArrayEmpty &= $i & "," next if not $iArrayEmpty Then MsgBox(0,"","Array is empty") Else $iArrayEmpty = Stringleft($iArrayEmpty,StringLen($iArrayEmpty)-1) MsgBox(0,"","Array contains values at position " & $iArrayEmpty) endif OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Phaser Posted March 31, 2010 Author Share Posted March 31, 2010 Hi JohnOne The only problem is, when the array is empty there are no 0's will this still work? Link to comment Share on other sites More sharing options...
JohnOne Posted March 31, 2010 Share Posted March 31, 2010 Yes. 0 is considered False I believe and an empty string also, anything else is considered true. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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