Sign in to follow this  
Followers 0
ReaImDown

how can I make this array work? (Complicated)

7 posts in this topic

#1 ·  Posted (edited)

basically, I want it to either show !@#$%^&*() or 1234567890, but I am not lucky enough to get either result... what am I doing wrong? hints are welcomed :D

$Chr = StringSplit("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21",",")
dim $Chr1
For $i = 1 to $chr[0]
    $Chr1 = StringSplit($Chr[$i],"|")
;   MsgBox(0,"",$chr1[2])
Next

for $i = 1 to $Chr1[0]
    MsgBox(0,"",$Chr1[1] & " = " & _HexToString($chr1[1]))
Next
Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites



Why not use a 2d array ?. Anyway try this, modifying your script

#include <string.au3>
$Chr = StringSplit("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21",",")
Dim $chr1[$chr[0] +1]
$chr1[0] = $chr[0]
For $i = 1 to $chr[0]
    $a = StringSplit($Chr[$i],"|")
    $chr1[$i] = $a[2]
Next

$s = ""
for $i = $Chr1[0] To 1 Step -1
    $s &= _HexToString($chr1[$i])
Next
MsgBox(0, "", $s)

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Why not use a 2d array ?. Anyway try this, modifying your script

#include <string.au3>
$Chr = StringSplit("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21",",")
Dim $chr1[$chr[0] +1]
$chr1[0] = $chr[0]
For $i = 1 to $chr[0]
    $a = StringSplit($Chr[$i],"|")
    $chr1[$i] = $a[2]
Next

$s = ""
for $i = $Chr1[0] To 1 Step -1
    $s &= _HexToString($chr1[$i])
Next
MsgBox(0, "", $s)
nice work, thanks for your time...and sorry, I screwed up in my post... I meant

msgbox(0,"","1")

msgbox(0,"","2")

msgbox(0,"","3")

msgbox(0,"","4")

msgbox(0,"","5") ....to 0

msgbox(0,"","!")

msgbox(0,"","@")

msgbox(0,"","#")

msgbox(0,"","$")...To )

I have never used a 2d array...would that be an easier way to go? I cant seem to find any examples.

Edited by ReaImDown

[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

Ok maybe this

#include <string.au3>
$Chr = StringSplit("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21",",")
Dim $chr1[$chr[0] +1]
Dim $chr2[$chr[0] +1]
$chr1[0] = $chr[0]
$chr2[0] = $chr[0]
For $i = 1 to $chr[0]
    $a = StringSplit($Chr[$i],"|")
    $chr2[$i] = $a[1]
    $chr1[$i] = $a[2]
Next

For $i = 1 To $Chr2[0]
    MsgBox(0, "", _HexToString($chr2[$i]))
Next

For $i = $Chr1[0] To 1 Step -1
    MsgBox(0, "", _HexToString($chr1[$i]))
Next

Share this post


Link to post
Share on other sites

Ok maybe this

#include <string.au3>
$Chr = StringSplit("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21",",")
Dim $chr1[$chr[0] +1]
Dim $chr2[$chr[0] +1]
$chr1[0] = $chr[0]
$chr2[0] = $chr[0]
For $i = 1 to $chr[0]
    $a = StringSplit($Chr[$i],"|")
    $chr2[$i] = $a[1]
    $chr1[$i] = $a[2]
Next

For $i = 1 To $Chr2[0]
    MsgBox(0, "", _HexToString($chr2[$i]))
Next

For $i = $Chr1[0] To 1 Step -1
    MsgBox(0, "", _HexToString($chr1[$i]))
Next

Thank you very much...1 more Q...would a 2d array be simpler? I have never used one, is it a more efficient way of coding?


[u][font="Century Gothic"]~я α и d γ ĵ . ċ . ѕ қ ϊ и и ε я~- My Programs -auto shutdownSleep funcdisallow programs[/font][/u]

Share this post


Link to post
Share on other sites

I have never used a 2d array...would that be an easier way to go? I cant seem to find any examples.

Look at the top of the forum page and you will see a link to the Wiki. Some good information exists there about Arrays.

http://www.autoitscript.com/wiki/Arrays

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Here's a 2d array example. It may be more efficient, depending on the format of your data

#include <string.au3>
$sData = StringReplace("30|29,31|28,32|2A,33|26,34|5E,35|25,36|24,37|23,38|40,39|21", "|", ",")
$Chr = StringSplit($sData, ",")
Dim $Chr2[$Chr[0]/2][2]
$j = 0
For $i = 1 To $Chr[0] Step 2
    $Chr2[$j][0] = $Chr[$i]
    $Chr2[$j][1] = $Chr[$i +1]
    $j += 1
Next

For $i = 0 To UBound($Chr2) -1
    MsgBox(0, "", _HexToString($Chr2[$i][0]))
Next
For $i = UBound($Chr2) -1 To 0 Step -1
    MsgBox(0, "", _HexToString($Chr2[$i][1]))
Next
Edited by picaxe

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