hcI Posted June 13, 2017 Posted June 13, 2017 (edited) Hello, i'm making a little script that lets users enter a question and if the script can't answer to, it ask what would be the answer (a bit like siri on IPhones). And I try to display the "supposed array" I still have an error.. I searched on Google and got nothing looked in the help file too.. I'm here to know if someone have a solution to my error please. Here is where $a and $b should become arrays : Dim $dossier = @AppDataDir & "\Siri2" Dim $chemin = $dossier & "\data.ini" Global $a = _InfoRead($chemin, 0) Global $b = _InfoRead($chemin, 1) with this function : Func _InfoRead($path, $mode = 0) If DirGetSize($dossier) = -1 Then Return SetError(-4) If Not FileExists($chemin) Then Return SetError(-5) Local $readed = IniReadSection($path, "data") If @error Then Return SetError(-3) $size = $readed[0][0] Local $return[$size] For $i = 1 To $size Step 1 $return[$i - 1] = $readed[$i][$mode] Next Return $return EndFunc and the thing that i don't understand is that, after _InfoRead return affected to $a, I can't use _ArrayDisplay because of error 1 "$aArray is not an array" (and same fpr the variable $b).. Can please someone help me to understand why is it doing this ? -hcI Edited June 13, 2017 by hcI Topic solved
anthonyjr2 Posted June 13, 2017 Posted June 13, 2017 When you call Return SetError(-4) or SetError(-5) you are returning an errorcode, not an array. If you check the return value of $a or $b is it returning an error? UHJvZmVzc2lvbmFsIENvbXB1dGVyZXI=
hcI Posted June 13, 2017 Author Posted June 13, 2017 16 minutes ago, anthonyjr2 said: When you call Return SetError(-4) or SetError(-5) you are returning an errorcode, not an array. If you check the return value of $a or $b is it returning an error? Yes you're right, it was returning an error because there was nothing in the data.ini ! I feel stupid now . Thanks man !
Valuater Posted June 13, 2017 Posted June 13, 2017 Since you are using an ini file Dim $chemin = $dossier & "\data.ini" Why not use iniread /inireadsection /etc.. 8)
hcI Posted June 13, 2017 Author Posted June 13, 2017 Func _InfoRead($path, $mode = 0) If DirGetSize($dossier) = -1 Then Return SetError(-4) If Not FileExists($chemin) Then Return SetError(-5) Local $readed = IniReadSection($path, "data") If @error Then Return SetError(-3) $size = $readed[0][0] Local $return[$size] For $i = 1 To $size Step 1 $return[$i - 1] = $readed[$i][$mode] Next Return $return EndFunc As you can see in the function, i am using IniReadSection. -hcI
hcI Posted June 13, 2017 Author Posted June 13, 2017 And there is 1hour ago, it was working but now when my script try to match the user's question to one that he knows, i get an error : For $i = 0 To Ubound($a, 1) Step 1 If $question = $a[$i] Then ; If the user's question match to one that he knows MsgBox(0, "Syrie II", $b[$i]) ; We answer it $IsDone = True ; We answered the question so we put it to True ExitLoop(1) ; And we break the search loop EndIf Next Array variable has incorrect number of subscripts or subscript dimension range exceeded.: If $question = $a[$i] Then If $question = ^ ERROR Was the same error than last time but now i can _ArrayDisplay $a and i get no errors with _InfoRead function PS: $question is the user's question in lower case and $b the answer array -hcI
jchd Posted June 13, 2017 Posted June 13, 2017 9 minutes ago, hcI said: For $i = 0 To Ubound($a, 1) Step 1 Fix with: For $i = 0 To Ubound($a) - 1 as AutoIt arrays' indices are 0..Ubound($a)-1 This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
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