Sign in to follow this  
Followers 0
SmOke_N

Array Position

3 posts in this topic

#1 ·  Posted (edited)

Ok, I am in logic hell, and I know I'm over complicating it.

I have 2 arrays.

Local $a_original[9] = [8, 0, 1, 2, 3, 4, 5, 6, 7]
Local $a_switch[5] = [4, 0, 2, 5, 7]; could be any number of elements from 0 - 7

I pass an index to place $a_switch after

Local $i_switch_at = 4

The final array needs to look like:

Local $a_final[9] = [8, 1, 3, 4, 0, 2, 5, 7, 6]

[0] is the number of index elements in the array.

Anyone have a simple solution to achieve this?

Edit:

Tired of messing with it... this looks like it may have it:

#include <array.au3>

Local $a_original[9] = [8, 0, 1, 2, 3, 4, 5, 6, 7]
Local $a_switch[5] = [4, 0, 2, 5, 7]
Local $i_switch_at = 4
;~ Local $a_final[9] = [8, 1, 3, 4, 0, 2, 5, 7, 6]
Local $s_string = ","

For $i = 1 To $a_switch[0]
    $s_string &= $a_switch[$i] & ","
Next

Local $s_out_put = ""
For $i = 1 To $a_original[0]
    If StringInStr($s_string, "," & $a_original[$i] & ",") = 0 Then
        $s_out_put &= $a_original[$i] & ","
    EndIf
    If $i = $i_switch_at + 1 Then $s_out_put &= "|"
Next

Local $a_split = StringSplit(StringTrimRight($s_out_put, 1), "|")
For $i = 1 To $a_switch[0]
    $a_split[1] &= $a_switch[$i] & ","
Next

Local $s_final_out = $a_split[1] & $a_split[2]
Local $a_final = StringSplit($s_final_out, ",")

_ArrayDisplay($a_final)
ConsoleWrite($s_final_out & @CRLF)
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'm thinking you might want to try something like this:

Local $s_string = ","
        For $i = 1 To $a_add[0]
            $s_string &= $a_add[$i] & ","
        Next
        
        Local $a_temp_delete[UBound($av_array) - $a_add[0]]
        For $i = 1 To $av_array[0]
            If StringInStr($s_string, "," & $av_array[$i] & ",") Then ContinueLoop
            $i_count += 1
            $a_temp_delete[$i_count] = $av_array[$i]
        Next
        
        Local $a_temp_insert = $a_temp_delete
        For $i = $a_add[0] To 1 Step -1
            _ArrayInsert($a_temp_insert, $i_lbound, $a_add[$i])
        Next

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

I'm thinking you might want to try something like this:

Local $s_string = ","
        For $i = 1 To $a_add[0]
            $s_string &= $a_add[$i] & ","
        Next
        
        Local $a_temp_delete[UBound($av_array) - $a_add[0]]
        For $i = 1 To $av_array[0]
            If StringInStr($s_string, "," & $av_array[$i] & ",") Then ContinueLoop
            $i_count += 1
            $a_temp_delete[$i_count] = $av_array[$i]
        Next
        
        Local $a_temp_insert = $a_temp_delete
        For $i = $a_add[0] To 1 Step -1
            _ArrayInsert($a_temp_insert, $i_lbound, $a_add[$i])
        NextoÝ÷ Ø6¥{ú®¢×©ä°6¥y«2¢é'£    赧ÚÑx8¦Â§!Ú'ßÛd!£  +bëjh(x-¢¯zÚyÚ"­YéíÂ+a²¶§X¤zØb±«­¢+Ø$%1½°ÀÌØíÍ}ÍÑÉ¥¹ôÅÕ½Ðì°ÅÕ½Ðì($%½ÈÀÌØí¤ôÄQ¼ÀÌØí}lÁt($$$ÀÌØíÍ}ÍÑÉ¥¹µÀìôÀÌØí}lÀÌØí¥tµÀìÅÕ½Ðì°ÅÕ½Ðì($%9áÐ($$($%1½°ÀÌØí}ѵÁ}±ÑmU ½Õ¹ ÀÌØíÙ}ÉÉ䤴ÀÌØí}lÁut($%½ÈÀÌØí¤ôÄQ¼ÀÌØíÙ}ÉÉålÁt($$%%MÑÉ¥¹%¹MÑÈ ÀÌØíÍ}ÍÑÉ¥¹°ÅÕ½Ðì°ÅÕ½ÐìµÀìÀÌØíÙ}ÉÉålÀÌØí¥tµÀìÅÕ½Ðì°ÅÕ½Ðì¤Q¡¸
½¹Ñ¥¹Õ1½½À($$$ÀÌØí¥}½Õ¹Ð¬ôÄ($$$ÀÌØí}ѵÁ}±ÑlÀÌØí¥}½Õ¹ÑtôÀÌØíÙ}ÉÉålÀÌØí¥t($%9áÐ(($%1½°ÀÌØí}ѵÁ}¥¹ÍÉÑmU   ½Õ¹ ÀÌØí}ѵÁ}±Ñ¤¬ÀÌØí}lÁutìôÀÌØí}ѵÁ}±Ñ($%½ÈÀÌØí¤ôÄQ¼ÀÌØí¥}±½Õ¹´Ä($$$ÀÌØí}ѵÁ}¥¹ÍÉÑlÀÌØí¥tôÀÌØí}ѵÁ}±ÑlÀÌØí¥t($%9áÐ($$($%½ÈÀÌØí¤ôÄQ¼ÀÌØí}lÁt($$$ÀÌØí}ѵÁ}¥¹ÍÉÑlÀÌØí¤¬ÀÌØí¥}±½Õ¹´ÅtôÀÌØí}lÀÌØí¥t($%9áÐ($$($%½ÈÀÌØí¤ôÀÌØí¥}±½Õ¹¬ÀÌØí}lÁtQ¼U  ½Õ¹ ÀÌØí}ѵÁ}¥¹ÍÉФ´Ä($$$ÀÌØí}ѵÁ}¥¹ÍÉÑlÀÌØí¥tôÀÌØíÙ}ÉÉålÀÌØí¥t($%9áÐ

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

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