will88 Posted May 2, 2009 Share Posted May 2, 2009 (edited) What it's suppost todo: Read Ini file to find out the length of the array. Then Declare 0-Length of array, with whatever is in the Settings.ini file Error: Global $Descriptions[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) Global $Descriptions[^ERROR Error: Array variable subscript badly formatted. Some of the code from my script: Global $ini = @HomeDrive & "\Settings.ini" $Arrays = IniRead($ini,"B","User","") If Not $Arrays = "" Then For $i = 0 to $Arrays $Read = IniRead($ini,"C","User" & $i,"") Global $Descriptions[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"D","User" & $i,"") Global $Usernames[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"E","User" & $i,"") Global $Passwords[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) Next Else Global $Arrays = False EndIf Settings file: [B] User=0 [C] User0=7E5999BB74C081B59C55BA5C946AB8399471754F5D62 [D] User0=7F5A98BD73C680B29D22BA2D9367B938 [E] User0=7F5D99C674C080B59C50BA5A9413B939 Thanks Edited May 2, 2009 by will88 Password-Keeper Link to comment Share on other sites More sharing options...
blakel Posted May 2, 2009 Share Posted May 2, 2009 Int he help file look at User Defined Functions -> Array Managment -> _ArrayPush _ArrayPop _ArrayAdd or look at IniReadSection Link to comment Share on other sites More sharing options...
martin Posted May 2, 2009 Share Posted May 2, 2009 (edited) What it's suppost todo: Read Ini file to find out the length of the array. Then Declare 0-Length of array, with whatever is in the Settings.ini file Error: Global $Descriptions[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) Global $Descriptions[^ERROR Error: Array variable subscript badly formatted. Some of the code from my script: Global $ini = @HomeDrive & "\Settings.ini" $Arrays = IniRead($ini,"B","User","") If Not $Arrays = "" Then For $i = 0 to $Arrays $Read = IniRead($ini,"C","User" & $i,"") Global $Descriptions[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"D","User" & $i,"") Global $Usernames[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"E","User" & $i,"") Global $Passwords[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) Next Else Global $Arrays = False EndIf Settings file: [B] User=0 [C] User0=7E5999BB74C081B59C55BA5C946AB8399471754F5D62 [D] User0=7F5A98BD73C680B29D22BA2D9367B938 [E] User0=7F5D99C674C080B59C50BA5A9413B939 Thanks You cannot set the element of an array which hasn't been declared, unlike like non-array variables. I haven't tested this but it might fix your problem- Global $ini = @HomeDrive & "\Settings.ini" ;we are going to use the value of $Arrays as an integer so cast it as a number (IniRead returns a string) Global $Arrays = Number(IniRead($ini,"B","User","")) If $Arrays <> 0 Then ;first declare the array with $Arrays elements Global $Descriptions[$Arrays] For $i = 0 to $Arrays-1 $Read = IniRead($ini,"C","User" & $i,"") Global $Descriptions[$i] =_StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"D","User" & $i,"") Global $Usernames[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) $Read = IniRead($ini,"E","User" & $i,"") Global $Passwords[$i] = _StringEncrypt(0,$Read,"Password",$Encrypt_Level) Next Else $Arrays = False EndIf Note that if $Arrays is 12 it means you want 12 elements. Arrays have the first element at 0 so your For $i loop must goi from 0 to $Array -1. Edited May 2, 2009 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now