Jump to content

function split


Recommended Posts

hi i make script : Collection of word (msgbox)

At first he was working well 

But now I do not know where the problem

this is script

#include <Array.au3>
Func _Split($BigVar)
  Local $SmallVar[1] = [0]
  For $i = 1 To StringLen($BigVar)
    _ArrayAdd($SmallVar, StringMid($BigVar, $i, 1))
    $SmallVar[0] += "s"
  Next
  Return $SmallVar
EndFunc
$Arrayfinal = _Split($Array[0] + $Array[1] + $Array[2] + $Array[3] + $Array[4])

$Array[0] = "m"
$Array[1] = "g"
$Array[2] = "b"
$Array[3] = "o"
$Array[4] = "x"


$Arrayfinal(0, "Msg", "Hello world ! ")

this is Problem : 

Kxng9I.jpg

Link to comment
Share on other sites

well where did you declare your array?

and why are you calling your _Split function before you added data "m""g""b""o""x", and shouldn't it be msgbox instead of mgbox?

declare an array on start of scriptand add its data on start of script and i think youl b fine

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
Share on other sites

  • Moderators

Well, being fine isn't necessarily true.

We don't concatenate strings with the plus "+" symbol.  We use an ampersand "&".

#include <Array.au3>
Func _Split($BigVar)
  Local $SmallVar[1] = [0]
  For $i = 1 To StringLen($BigVar)
    _ArrayAdd($SmallVar, StringMid($BigVar, $i, 1))
    $SmallVar[0] += "s"
  Next
  Return $SmallVar
EndFunc

Global $Array[5]
$Array[0] = "m"
$Array[1] = "g"
$Array[2] = "b"
$Array[3] = "o"
$Array[4] = "x"

Global $Arrayfinal = _Split($Array[0] & $Array[1] & $Array[2] & $Array[3] & $Array[4])
_ArrayDisplay($Arrayfinal)

; no idea what the heck you're doing here
;~ $Arrayfinal(0, "Msg", "Hello world ! ")

Your function is really redundant though.

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.

Link to comment
Share on other sites

he should be fine for error that he displayed

as he stated 

At first he was working well 

Who am i to say otherwise if its working for him with all that strange string Len and Mid on array instead of UBound and array element with calling func from variable and constantly += "s" on first array element... 

Eather way it looks to me that he is trying this

#include <Array.au3>

Local $Array[6]
$Array[0] = "m"
$Array[1] = "s"
$Array[2] = "g"
$Array[3] = "b"
$Array[4] = "o"
$Array[5] = "x"
$Arrayfinal = _ArrayToString($Array, '')

Call($Arrayfinal, 0, "Msg", "Hello world ! ")

but all this can be wrong because there isn't a good description of what the OP is trying to do

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.

 
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...