Jump to content

'Subscript used with non-Array variable'


Recommended Posts

No matter how I change it up, or no matter what I do, it always gives me that dang error ><

For $string1 = 0 To 1
        _IniWrite("Current.ini", "Ticket", "Ticket", "0")
        Next
        $hey = IniReadSectionNames("Current.ini")
        For $x = 1 To $hey[0]
        $yo = _StringEncrypt(0, $hey[$x], 1, 1)
        If $yo = "Ticket" Then
            ExitLoop
        EndIf
        Next
        $doubleticket = IniReadSection("Current.ini", $yo)
        $string = GUICtrlRead($inputt)
        
;----------------------------------------------------------------------------HERE
                For $i = 1 To $doubleticket[0][0]
;------------------------------------------^^^^^^--------------------------------HERE  Above the ^^^^
            If $string = "" Then
                MsgBox(0, "", "You must put in your ticket first!")
                _SetState($Form5, $Form1, $Form1)
            ElseIf $string = $doubleticket[$i][1]
                MsgBox(0,"","DUAL")
            EndIf
        Next

I first thought I could just 'decrypt' through it within the IniReadSection without having to find '$yo'. So I thought that might have been the problem so I first FOUND the section name and made sure it was there. And it came back positive, it could retrieve the section name. Yet STILL $doublecheck[0][0] keeps coming back with that error.

My coding has been sloppy today, making a whole bunch of silly mistakes.... Maybe I'm missing something here? ><

Link to comment
Share on other sites

No matter how I change it up, or no matter what I do, it always gives me that dang error ><

For $string1 = 0 To 1
        _IniWrite("Current.ini", "Ticket", "Ticket", "0")
        Next
        $hey = IniReadSectionNames("Current.ini")
        For $x = 1 To $hey[0]
        $yo = _StringEncrypt(0, $hey[$x], 1, 1)
        If $yo = "Ticket" Then
            ExitLoop
        EndIf
        Next
        $doubleticket = IniReadSection("Current.ini", $yo)
        $string = GUICtrlRead($inputt)
        
;----------------------------------------------------------------------------HERE
                For $i = 1 To $doubleticket[0][0]
;------------------------------------------^^^^^^--------------------------------HERE  Above the ^^^^
            If $string = "" Then
                MsgBox(0, "", "You must put in your ticket first!")
                _SetState($Form5, $Form1, $Form1)
            ElseIf $string = $doubleticket[$i][1]
                MsgBox(0,"","DUAL")
            EndIf
        Next

I first thought I could just 'decrypt' through it within the IniReadSection without having to find '$yo'. So I thought that might have been the problem so I first FOUND the section name and made sure it was there. And it came back positive, it could retrieve the section name. Yet STILL $doublecheck[0][0] keeps coming back with that error.

My coding has been sloppy today, making a whole bunch of silly mistakes.... Maybe I'm missing something here? ><

If it can't read the section, no array is returned. Add some error checking:
$doubleticket = IniReadSection("Current.ini", $yo)
        If @error Then 
            MsgBox(16, "Error", "Failed to read INI section [" & $yo & "]")
        Else
            $string = GUICtrlRead($inputt)
            For $i = 1 To $doubleticket[0][0]
                If $string = "" Then
                    MsgBox(0, "", "You must put in your ticket first!")
                    _SetState($Form5, $Form1, $Form1)
                ElseIf $string = $doubleticket[$i][1]
                    MsgBox(0,"","DUAL")
                EndIf
            Next
        EndIf

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

If it can't read the section, no array is returned. Add some error checking:

$doubleticket = IniReadSection("Current.ini", $yo)
        If @error Then 
            MsgBox(16, "Error", "Failed to read INI section [" & $yo & "]")
        Else
            $string = GUICtrlRead($inputt)
            For $i = 1 To $doubleticket[0][0]
                If $string = "" Then
                    MsgBox(0, "", "You must put in your ticket first!")
                    _SetState($Form5, $Form1, $Form1)
                ElseIf $string = $doubleticket[$i][1]
                    MsgBox(0,"","DUAL")
                EndIf
            Next
        EndIf

:)

I broke it down for the IniReadSection... $yo can read it. So having the EXACT title name ($yo) put into that shouldn't be the cause of the error should it? ><

And you're right... It can't read it, but why?!... I have the same method to read individual keys (using encryptions etc) in the EXACT SAME .ini file... I can obtain the Section name... What else would be causing this not able to read it? ><

Link to comment
Share on other sites

no idea man..i think i t might be in the encryption... thought the error you tell me comes from READING the file... so maybe it doesn't exst? the section isn't there beyond that i have no idea what could be bringin back an error... bug maybe?

Link to comment
Share on other sites

Look at your ini file, make sure there is an "=" after each keyname. Even with encrypted keys, IniReadSection expects to see the "=" (in my testing a value is optional).

Yep.... Heres the .ini... Not entirely sure which section is the Ticket section... But it's in there beings I have only 3 sections created on my program.

[E8964D946FB0608D]

E8964D946FB0608D=EAE34EE1

[E8954EE76FCF678489B19537]

E8954EE76FCF678489B19537=9792

[EB904D926ECC608D89B19644A999B85BDC0ABD90E3198C1B]

EBE74EE16FBB678A88C2=979249956ACA1D8F

Link to comment
Share on other sites

Yep.... Heres the .ini... Not entirely sure which section is the Ticket section... But it's in there beings I have only 3 sections created on my program.

In that case, I would agree with CodyBarrett. Maybe test with an unencrypted ini file.
Link to comment
Share on other sites

In that case, I would agree with CodyBarrett. Maybe test with an unencrypted ini file.

Meh... Why wouldn't it work with unencrypted... Thats what the function is meant for xD. I mean it is returnined $yo to me correctly (the section name Ticket).... So why is it messing up 2 lines down when its trying to read the section name again.... ><

Link to comment
Share on other sites

If it can't read the section, no array is returned. Add some error checking:

:)

Like PsaltyDS mention, add some error checking don't assume it can read it. The problem of your script is the line below:

$doubleticket = IniReadSection("Current.ini", $yo)

At this point of your script the value of $yo is equal to Ticket but your ini file section are like E8954EE76FCF678489B19537 so $doubleticket is not an array.

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Like PsaltyDS mention, add some error checking don't assume it can read it. The problem of your script is the line below:

$doubleticket = IniReadSection("Current.ini", $yo)

At this point of your script the value of $yo is equal to Ticket but your ini file section are like E8954EE76FCF678489B19537 so $doubleticket is not an array.

No no... $yo is equivalent to 'De-crypting' the section names until it finds Ticket... So when $yo is placed in $doublecheck it is re-doing that De-crypt which would return the de-crypt in $doublecheck to Ticket....

As far I know anyways ><

Link to comment
Share on other sites

For $x = 1 To $hey[0]
        $yo = _StringEncrypt(0, $hey[$x], 1, 1)
        If $yo = "Ticket" Then
            ExitLoop
        EndIf
        Next
        $doubleticket = IniReadSection("Current.ini", $yo)
This are the step of you script

1) Loop

2) $yo = Decrypt()

3) $yo = Ticket exitloop

4) IniReadSection("Current.ini", Ticket)

5) message error non-Array variable.

Note: I don't see anything encrypting $yo value

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

For $x = 1 To $hey[0]
        $yo = _StringEncrypt(0, $hey[$x], 1, 1)
        If $yo = "Ticket" Then
            ExitLoop
        EndIf
        Next
        $doubleticket = IniReadSection("Current.ini", $yo)
This are the step of you script

1) Loop

2) $yo = Decrypt()

3) $yo = Ticket exitloop

4) IniReadSection("Current.ini", Ticket)

5) message error non-Array variable.

Note: I don't see anything encrypting the $yo value

If $yo = "Ticket" Then

That does not declare it as Ticket... That's just getting the return value of $yo... $yo is and will stay [$yo = _StringEncrypt(0, $hey[$x], 1, 1)] no matter where it is put. Simply asking for the return of it doesn't change what it is declared as in the first place :S.

Link to comment
Share on other sites

If $yo = "Ticket" Then

That does not declare it as Ticket... That's just getting the return value of $yo... $yo is and will stay [$yo = _StringEncrypt(0, $hey[$x], 1, 1)] no matter where it is put. Simply asking for the return of it doesn't change what it is declared as in the first place :S.

$yo = _StringEncrypt(0, $hey[$x], 1, 1) this line decrypt the value of $hey[$x] and assigned to $yo so $yo is equal Ticket not E8954EE76FCF678489B19537. If you want to be sure right before this line $doubleticket = IniReadSection("Current.ini", $yo) add ConsoleWrite('Value: ' & $yo & @CRLF) then you can see what is the value of $yo

Note:

Even better,

If $yo = "Ticket" Then
            ExitLoop
        EndIf

Before ExitLoop add $yo = $hey[$x] that should fix your script

Edited by Danny35d
AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Link to comment
Share on other sites

Like PsaltyDS mention, add some error checking don't assume it can read it. The problem of your script is the line below:

$doubleticket = IniReadSection("Current.ini", $yo)

At this point of your script the value of $yo is equal to Ticket but your ini file section are like E8954EE76FCF678489B19537 so $doubleticket is not an array.

this makes sense... Inireadsection() reads as is not decrypting it as it goes... and it's nearly impossible to read that properly withought decrypting.... TRY a NORMAL ini... see if that makes your script work

Link to comment
Share on other sites

Well I got a new problem... Not really a scripting problem, but just a problem problem xP.

Now I have accomplished having it check to see if that ticket is in the .ini file, and if it is, do not let them use the ticket. BUT what I didn't think of was:

When I give them their ticket it has to match their username on the program and then an amount of money after the username with a comma, like so: Hey,100 Which encrypts with password:1 and level: 1 to :

EBE24E926EBC1CFA8CCA914AAD9D

But the bad thing is, the person 'Hey' could want another 100 ticket later on.... So if I were to type in Hey,100 again, that same encryption would appear, and 'Hey' wouldn't be able to use that on the ticket checker as it has already been used.

What I'm asking help on, how would I be able to allow that SECOND ticket (and third, and fourth, etc) to use it, but NOT allow duplicate use of one ticket?

My only idea was create another whole lot of code to read and write how many times that ticket has been used and thats how I would encrypt.... Ex: Hey,100 Hey,1001, Hey,1002 But that would then require the user to tell me how many times he has used that ticket, and could lie to me saying hes used it 5 times (when he has only used it once)... Then get 4 free tickets to use...

Any suggestions would be great.... If only I could get a server/client going this would be SO MUCH easier... (Stupid router problems :) )

Link to comment
Share on other sites

What I'm asking help on, how would I be able to allow that SECOND ticket (and third, and fourth, etc) to use it, but NOT allow duplicate use of one ticket?

My only idea was create another whole lot of code to read and write how many times that ticket has been used and thats how I would encrypt.... Ex: Hey,100 Hey,1001, Hey,1002 But that would then require the user to tell me how many times he has used that ticket, and could lie to me saying hes used it 5 times (when he has only used it once)... Then get 4 free tickets to use...

Well, if you're actually giving them a new ticket, then why not issue/track that ticket as "Hey,100-xxxx" where xxxx is some unique identifier like a time/date stamp or even just a simple increment like you've already mentioned: Hey,100-1, Hey,100-2, etc?
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...