Jump to content

Stringsplit error


Erik.
 Share

Recommended Posts

Hi,

This is my peace of code but i get the error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

This is my code:

For $i2 = 0 to IniRead($server & "\" & $map & "\members.dbs","aantal","1","")

$read2 = IniRead($server & "\" & $map & "\" & "members.dbs","members",$i2,"")

$split = StringSplit($read2,"-")

msgbox(0,"",$split[1])

If GUICtrlRead($voornaam) = $split[2] And GUICtrlRead($achternaam) = $split[3] Then

GUICtrlSetBkColor($voornaam,0xff0000);rood

GUICtrlSetBkColor($achternaam,0xff0000);rood

$read1 = GUICtrlRead($info)

GUICtrlSetData($info,"Voornaam/Achternaam (bestaat al)" & @CRLF & $read1)

MsgBox(48,"Error","013" & @CRLF & "Voornaam/Achternaam bestaat al")

$er3=1

ExitLoop

Else

GUICtrlSetBkColor($voornaam,0x00ff00);groen

GUICtrlSetBkColor($achternaam,0x00ff00);groen

$read1 = GUICtrlRead($info)

GUICtrlSetData($info,"Voornaam/Achternaam (goed)" & @CRLF & $read1)

$er3=0

EndIf

Next

EndIf

I don't know what i aim doing wrong...

This is my ini file:

[aantal]

1=0

[members]

1=0001-memberone-lastname

2=0002-membertwo-lastname

3=0003-memberthree-lastname

I want to get the string 2 and 3 member...-and lastname is there are the same as controlread the it is ok

But i get that error

I do not know what i am doing wrong

When i ask string[1] it works i get 0001 or someother but when i ask other string it won't work any more:(

Can someone help me please

I little problem, hard to find and fix

Link to comment
Share on other sites

I will try to use it and i hope it will work.

The problem the string i get back needs to be psingsplitted again so i can get member name and lastname and carndnumber.

EDIT:

Still got the same error...

Edited by Erik.

I little problem, hard to find and fix

Link to comment
Share on other sites

This works fine for me:

$number = IniRead("test.ini", "aantal", "1", "")
For $i2 = 1 To Number($number)
    $read2 = IniRead("test.ini", "members", $i2, "")
    $split = StringSplit($read2, "-")
    MsgBox(0, "", $split[1])
    MsgBox(0, "", $split[2])
    MsgBox(0, "", $split[3])
Next

Test.ini

[aantal]
1=3
[members]
1=0001-memberone-lastname1
2=0002-membertwo-lastname2
3=0003-memberthree-lastname3
Link to comment
Share on other sites

still got the error:

$number=IniRead($server & "\" & $map & "\members.dbs","aantal","1","")

For $i2 = 0 to Number($number)

$read2 = IniRead($server & "\" & $map & "\" & "members.dbs","members",$i2,"")

$split = StringSplit($read2,"-")

MsgBox(0, "", $split[1])

MsgBox(0, "", $split[2])

MsgBox(0, "", $split[3])

Next

I realy don't know what i am doing wrong

I little problem, hard to find and fix

Link to comment
Share on other sites

  • Developers

there is no member 0 so maybe :

$read2 = IniRead($server & "\" & $map & "\" & "members.dbs","members",$i2+1,"")

or test for the $split[0] value being 3 before using $split[1] - $split[3]

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Moderators

Replace MsgBox() with _ArrayDisplay() to see what the MsgBox() should be seeing, you should always see 3 elements for every example. (Just in case you don't know to do it, add #include <array.au3> at the top of your script).

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

Hi,

Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

You need to check if the function really return an array, or if it return that mutch elements...

For $i2 = 0 To IniRead($server & "\" & $map & "\members.dbs","aantal","1","")
    $read2 = IniRead($server & "\" & $map & "\" & "members.dbs","members",$i2,"")
    $split = StringSplit($read2, "-")
    
    If UBound($split) > 3 And GUICtrlRead($voornaam) = $split[2] And GUICtrlRead($achternaam) = $split[3] Then
        GUICtrlSetBkColor($voornaam,0xff0000);rood
        GUICtrlSetBkColor($achternaam,0xff0000);rood
        
        $read1 = GUICtrlRead($info)
        GUICtrlSetData($info,"Voornaam/Achternaam (bestaat al)" & @CRLF & $read1)
        MsgBox(48,"Error","013" & @CRLF & "Voornaam/Achternaam bestaat al")
        $er3=1
        ExitLoop
    Else
        GUICtrlSetBkColor($voornaam,0x00ff00);groen
        GUICtrlSetBkColor($achternaam,0x00ff00);groen 
        $read1 = GUICtrlRead($info)
        GUICtrlSetData($info,"Voornaam/Achternaam (goed)" & @CRLF & $read1)
        $er3=0
    EndIf
Next

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

Hi,

Thats works fine thanks :P

I still do not know why that works and my solution not...

I used my solution above in my script and it works fine so i wanted to use it again but it wont work any more

but this works fine

Thanks!

I little problem, hard to find and fix

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