Jump to content

how can I make this array work? (Complicated)


Recommended Posts

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]
Link to comment
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)
Link to comment
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)
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]
Link to comment
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
Link to comment
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]
Link to comment
Share on other sites

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
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...