Jump to content
Sign in to follow this  

conversion between _array type

Recommended Posts

:idea: there it is,

2 silly functions to convert 0 base index array and 1 base index array...

i guest the _array UDF should have something like that ...

1base index array is kind of array with array size at position 0

ex. stringSplit

#include <Array.au3>

func array0ToArray1( byref $a0 )
   local $a1[ubound($a0) + 1], $i

   for $i = 1 to ubound($a0)
      $a1[$i] = $a0[$i - 1]
   $a1[0] = ubound($a0)
    return( $a1 )

func array0FromArray1( byref $a1 )
   local $a0[$a1[0]], $i

   for $i = 0 to $a1[0] - 1
      $a0[$i] = $a1[$i + 1]
   return( $a0 )

global $a0
global $a1 = stringSplit( "qwerty", ""  )

_arrayDisplay($a1, "")
$a0 = array0FromArray1( $a1 )
_arrayDisplay($a0, "")
$a1 = array0ToArray1( $a0 )
_arrayDisplay($a1, "")
Edited by JoeCool

Share this post

Link to post
Share on other sites

Here is your example rewritten using existing functions already in the UDF include file, Array.au3.

#include <Array.au3>

Local $a1 = StringSplit("qwerty", "")

_ArrayDisplay($a1, "")
_ArrayDelete($a1, 0) ; Instead of array0FromArray1( $a1 )
_ArrayDisplay($a1, "")
_ArrayInsert($a1, 0, UBound($a1)) ; Instead of array0ToArray1( )
_ArrayDisplay($a1, "")


lol ur right ...

I didn't think hard enough :)

I don't use the _array package, i have since long time my own few packages

who do all that stuff (array, matrix etc), i was just writing a script for someone

and wrote those 2 functions on the fly for him ...

i should always think before coding :(


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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...