Sign in to follow this  
Followers 0
Neoborn

Array: Delete Empty Element From Array

12 posts in this topic

#1 ·  Posted (edited)

Hello Guys,

I have a one dimensional array that I am creating dynamically and just need to remove any empty array elements from it:

I paste into Gui:

123456
123456
123456
123456
123456
"       "

and then I chop this up into elements but I always end up with an empty element at the end because of the copy pasting process, I would really like to know how to remove this.

Thanks in advance,

Neoborn

Edited by Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites



#include <array.au3>
Dim $a[7]
$a[0] = 123456
$a[1] = 123456
$a[2] = 123456
$a[3] = "   "
$a[4] = 12
$a[5] = 123456
$a[6] = "        "

_ArrayDisplay($a)
$i = 0
While $i < UBound($a)
    If IsString($a[$i]) Then
        MsgBox(0, "", "Bingo: " & $i)
        _ArrayDelete($a, $i)
        $i += 1
    EndIf
    $i += 1
WEnd
_ArrayDisplay($a)


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Much easier to just step thru in reverse with a For/Next loop:

#include <array.au3>

For $i = UBound($a) - 1 To 0 Step -1
    If StringStripWS($a[$i], 8) = "" Then _ArrayDelete($a, $i)
Next

:rolleyes:

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I will check these out to see if they work later, in the meantime can you tell me why I seem to be having a problem with the Checkbox in this code and checking to see if it's checked or not?

#include <GUIConstants.au3>
#include <Array.au3>

#Region ### ÕTÛÙHÕRHÙXÝ[ÛÈÈÈÌÍÑÜLWÌHHÕRPÜX]J   ][ÝÑY[ÈTÓÈÛÂgV÷C²Â#Â3#Â2ÂR¢b33c´w&÷WÒuT7G&Ä7&VFTw&÷WgV÷C²gV÷C²Ô°À°ÄÌÜ°ÌÄ̤(ÀÌØí¥ÐÄôU%
Ñɱ
ÉѥРÅÕ½ÐìÅÕ½Ðì°ÄÌ°ÄØ°ÄÈÄ°289)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrÜX]QÜÝ
    ][ÝÉ][ÝËM

ÌLÊBÌÍÒ[]HHÕRPÝÜX]R[BgV÷C´çWCgV÷C²ÂS"Â3"Â32Â#¤uT7G&Å6WE7FFRÓÂb33c´uTôD4$Ĥ(ÀÌØí1°ÄôU%
Ñɱ
ÉÑ1° ÅÕ½ÐíQ½Ñ°ÅÕ½Ðì°ÄÔÈ°ÄÔ°Èà°Äܤ(À6;Checkbox1 = GUICtrlCreateCheckbox("Cases?", 152, 64, 57, 41)
$Button1 = GUICtrlCreateButton("Exit&#33É][ÝËMMÌ
KK
BÌÍÐ]ÛHÕRPÝÜX]P]Û   ][ÝÑÛÉV÷C²ÂSBÂ#CÂCÂ#R¤uT7G&Ä7&VFTw&÷WgV÷C²gV÷C²ÂÓÂÓÂÂ)=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°È¤()¥´ÀÌØí%¹Á}ÉÌ°ÀÌØí¤()U%MÑMate(@SW_SHOW);create the GUI
#EndRegion ### END Koda GUI section ###

WhileB  ÌÍÛÙÈHÕRQÙ]ÙÊ
BÝÚ]Ú    ÌÍÛÙÂØÙH ÌÍÑÕRôUdTåEô4Äõ4P¢¢66Rb33c´'WGFöã ¢b33c´ç÷ÌÄôU%
ÑɱI ÀÌØí¥ÐÄ°À¤íÉÑ¡½¹Ñ¹Ñ̽ѡ½¹Ñɽ°(   $Inp_res2 = StringSplit($Inp_res1, @CR);split the contents at HØXYÙH]ÚXÝ    ÌÍÚHHPÝ[
    Ì3c´ç÷&W3"ÂÒ¢bb33c¶fwC²RFVà¢×6t½à Ðà°ÅÕ½Ðí]ɹ¥¹ÅÕ½Ðì°ÅÕ½Ðí1¥µ¥ÑѼ±Õ¹¡¥¹ÄÔ5M
Edited by Neoborn

~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

I will check these out to see if they work later,

they do work, otherwise we would not have posted them!


__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Share this post


Link to post
Share on other sites

Now now, no need to be sensitive, If you would like me to reword this for you here:

"Thanks very much guys for your efforts, currently I don't have time right now to try these to see if I can get them working. I will let you know how it goes. Again thanks very much for your help"

Maybe relax, not be so defensive and just know that your stuff works, so then it doesn't matter what others say.

I hope this multitude of words clarifies things for you!


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Now now, no need to be sensitive, If you would like me to reword this for you here:

Don't mind him, he's just cranky cause whenever somebody want to get rid of something they just "pipe it to /dev/null". :rolleyes:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

#include <GUIConstants.au3>
#include <Array.au3>

$Form1_1HÕRPÜX]][ÝÑY[ÈTÓÈÛÛ ][ÝËNKÌKNLËLMJBÌÍÑÜÝÒuT7G&Ä7&VFTw&÷WgV÷C²gV÷C²ÂRÂÂ3rÂ32¢b33c´VFCÒuT7G&Ä7&ѥРÅÕ½ÐìÅÕ½Ðì°ÄÌ°ÄØ°ÄÈÄ°Èàä¤)U%
Ñɱ
ÉÑɽÕÀ ÅÕ½ÐìÅÕ½Ðì°´ä, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("", 144, 0, 68, 31ÊBÌÍÒ[]HHÕRPÝÜX]R[]
    ][ÝÒ[]I][ÝËMLÌÌËJBÕ7G&Å6WE7FFRÓÂb33c´uTôD4$ÄR¢b33c´Æ&VÃÒuT7G&Ä7&VFTÆ&VÂgV÷íQ½Ñ°ÅÕ½Ðì°ÄÔÈ°ÄÔ°Èà°Äܤ(ÀÌØí
¡­½àÄôU%
Ñɱ
ÉÑ
¡­½à ÅÕ½;Cases?", 152, 64, 57, 41)
$Button1 = GUICtrlCreateButton("E]  ÌÌÎÉ][ÝËMMÌ
KK
BÌÍÐ]ÛHÕRPÝÜX]P]Û   ]÷C´vògV÷C²ÂSBÂ#CÂCÂ#R¤uT7G&Ä7&VFTw&÷WgV÷C²gV÷C²ÂÓÂÓİĤ()=ÁÐ ÅÕ½Ðí]¥¹Q¥Ñ±5Ñ¡5½ÅÕ½Ðì°È¤()¥´ÀÌØí%¹Á}ÉÌ°ÀÌØí¤()UISetState(@SW_SHOW);create the GUI

While 1
    $nMsg = GUIGetMsg()
 ÝÚ]Ú    ÌÍÛÙÂØÙH ÌÍÑÕRWÑUSÐÓÔÑB66Rb33c´'WGFöã ¢b33c´ç÷&W3ÒuT7G&Å&VBb33c´VFCÂÉÑ¡½¹Ñ¹Ñ̽ѡ½¹Ñɽ°(ÀÌØí%¹Á}ÉÌÈôMÑÉ¥¹MÁ±¥Ð 036;Inp_res1, @CR);split the contents at the carriage return characters
    ÌÍÚHHPÝ[
    ÌÍÒ[ÜÌJHHBYb33c¶fwC²RFVà¢×6t&÷CÂgV÷Cµv&æærgV÷C²ÂgV÷C´¥µ¥ÑѼ±Õ¹¡¥¹ÄÔ5M

Edited by poisonkiller

Share this post


Link to post
Share on other sites

Thanks Poison. Works nice.


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

Do you guys know how I can find out the character codes for each entry for instance if the number was

*123456 and the * represents some kind of @CR or @LF how can I find out what those invisible chr's are?


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Do you guys know how I can find out the character codes for each entry for instance if the number was

*123456 and the * represents some kind of @CR or @LF how can I find out what those invisible chr's are?

Hmmm... again I guess the help file is evasive ... or... you feel that asking the question here would make it easier on you rather than sifting through the multitudes of functions in the help file, or using the search function provided to you from the forums.

Look at Chr().

Edit:

Also take a look at Asc().

Edited by SmOke_N

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.

Share this post


Link to post
Share on other sites

I guess that possibly figuring that I had already searched the help file but could not come up with either

A) the correct keywords to return the required response :rolleyes: Something to point me in the right direction

is beyond your current level of possibilities / reasons?

Also thank you for your help.

Hmmm... again I guess the help file is evasive ... or... you feel that asking the question here would make it easier on you rather than sifting through the multitudes of functions in the help file, or using the search function provided to you from the forums.

Look at Chr().

Edit:

Also take a look at Asc().


~Projects~1. iPod Ejector 1.0 - Tool Used To Eject iPod in Windows - Uses DevEject.exe :P2. SmartFTP Close Popup Tool - Closes reminders from freeware SmartFTP.~Helpful Links For New Users~1. LXP's Learning AutoIT PDF Guide - <<< Go here for a PDF Guide on learning AutoIT from the ground up!<<<2. AutoIt 1-2-3 <<<Want to learn more about AutoIT quickly? Go Here<<<3. How To Install The Beta And Production Versions Of AutoIT / SciteAutoIT

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