lucas9

Error: Subscript used on non-accessible variable

5 posts in this topic

Hi everyone

I have this function to convert some data:

func ConversionDatosCapturados($in)
    Global $tmp_filename = "tmp_" & GenerateName("cccccccccccccccccc") & ".jg"
    FileWrite($tmp_filename,$in[0]) 
    Global $in_convert = FileRead($tmp_filename)
    FileDelete($tmp_filename)
    Return $in_convert
EndFunc

This funcion is running in one of my computers without any error, this week i have copied all the script to a new computer and i have got this error:

Quote

Line 5 (File "C:\xxx)

FileWrite($tmp_filename,$in[0])

FileWrite($tmp_filename,$in^ERROR

Error: Subscript used on non-accessible variable.

if i remove the "[0]" error dissapears but this "[0]" makes the data conversion.

Someone knows any solution?

Thanks in advance.
 

Share this post


Link to post
Share on other sites



Check that the variable $in passed actually is an array. In your problem-case, it clearly isn't.


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

thanks.

i can not understand your reply. why you say that $in is not an array?

 

regards

Share this post


Link to post
Share on other sites

Because of the error message! You aren't passing an array to the function, at least not in the case where the error pops up. It generally comes from a previous unchecked error in the calling code.

Then you shouldn't declare global variables inside a function.

Also may I ask what's the intent of the function?


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 here
RegExp tutorial: enough to get started
PCRE 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)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

You can tell the $in is not an array in this case because the error specifically says so. Whatever you're passing in as the argument for that method is apparently not an array.

If you're passing in something that is supposed to be an array and it works on another computer, then there's a difference between what happens on both computers. Whatever is used as the argument for that function call is somehow an array on one computer but not on the other one. However, there are myriads of conceivable causes for that; so for more help, please show how you call the function and how your script decides what goes in as an argument. (Totally random example, first thing that comes to my mind: say you StringSplit a filename from some hardcoded diractory and feed the result to this function... If the directory exists on one computer but not on another computer you would get this problem.)

Edited by SadBunny

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
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