Jump to content
Sign in to follow this  

_arraydelete() is changing elements?

Recommended Posts


I'm trying to make a function that scrambles a string (puts its characters in random order).

But for some reason, my function will change the contents of the string, resulting in extra copies of the same character in my output string. Here's my test code:

#include <misc.au3>
#include <array.au3>

msgbox(0,"",$newWord&" "&$word)

func scramble($str)
    local $temp=$str
    dim $newArray[1]
    for $c=0 to $tMax-1
    return $newStr

Why is it adding duplicate characters?

Share this post

Link to post
Share on other sites

I solved the problem. In the For loop, I needed to add a 1 flag to Random() so that it would generate integer values only.

Share this post

Link to post
Share on other sites

Don't know. But your code seems to trigger a _arrayadd() error on its last For-Next loop. Might be related.

;; add following debug #directive to top of your code.
;; error result.
;; LINE: 1-0:         _arrayadd($newArray,$tempArray[$select])


Oops ... to late.

(argg, I always forget its the line above the one that displays the error. :) )

Edited by iEvKI3gv9Wrkd41u

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...

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