Search the Community
Showing results for tags 'subscript error'.
-
Script running good but error in line 7. When i run this script : #include <IE.au3> #include <Array.au3> $oIE = _IEAttach ("Shop") $oTable = _IETableGetCollection ($oIE, 1) $aTableData = _IETableWriteToArray ($oTable) For $inumber = 1 To UBound($aTableData) -1 $table = $aTableData[4][$inumber] MsgBox(0, "", $table) Next I got Error: array variable has incorrect number of subscripts or subscript dimension range exceeded
- 17 replies
-
- subscript error
- range
-
(and 1 more)
Tagged with:
-
I am coming across a certain error in a certain script #comments-start Augmented Reality Setup Pre-Alpha testing Himanshu Goel 23rd March 2012- Friday #comments-end #include <guiconstantsex.au3> #include <windowsconstants.au3> #include <gdiplus.au3> #include <array.au3> #include <winapi.au3> #include "_Fann.au3" Dim $pixelarray Local $file_in="marker.jpg" Local $file_out="detect1.jpg" _GDIPlus_Startup() _FileImageToArray($file_in, $pixelarray) for $x=1 to $width for $y=1 to $height if $pixelarray[$x][$y]="000000" Then $pixelarray[$x][$y]="FFCC33" EndIf Next Next _FileArrayToImage($file_out, $pixelarray) MsgBOx(0,"Done", "Done!") _GDIPlus_Shutdown() ;Functions ;Convert Image to pixel color information array Func _FileImageToArray($filename, ByRef $aArray) Local $Reslt, $stride, $format, $Scan0, $iW, $iH, $hImage Local $v_Buffer, $width, $height Local $i, $j $hImage = _GDIPlus_ImageLoadFromFile($filename) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") Dim $aArray[$width][$height] For $i = 0 To $iW - 1 For $j = 0 To $iH - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$i][$j] = Hex(DllStructGetData($v_Buffer, 1), 8) Next Next _GDIPlus_BitmapUnlockBits($hImage, $Reslt) _GDIPlus_ImageDispose($hImage) Return EndFunc ;==>_FileImageToArray ;Convert pixel information array to Image Func _FileArrayToImage($filename, $aArray) Local $iW = UBound($aArray, 1), $iH = UBound($aArray, 2), $sResult = "" Local $hBMP, $hImage1, $Reslt, $width, $height, $stride, $format, $Scan0 Local $sResult, $v_BufferA Local $i, $j $hBMP = _WinAPI_CreateBitmap($iW, $iH, 1, 32) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $Reslt = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") $v_BufferA = DllStructCreate("DWORD[" & $height * $width & "]", $Scan0) For $j = 0 To $height - 1 For $i = 0 To $width - 1 DllStructSetData($v_BufferA, 1, Execute("0x" & $aArray[$i][$j]), ($j * $width) + $i + 1) ; "+1" - base 1. Next Next _GDIPlus_BitmapUnlockBits($hImage1, $Reslt) _GDIPlus_ImageSaveToFile($hImage1, $filename) _GDIPlus_ImageDispose($hImage1) _WinAPI_DeleteObject($hBMP) Return EndFunc ;==>_FileArrayToImage It gives me an invalid subscript error where as this code works perfectly Error Code C:Documents and SettingsOwner.HOMEMy DocumentsAugmented Reality ResearchPattern RecognitionNeural Network WORKINGpre-alpha 1.au3 (48) : ==> Array variable subscript badly formatted.: Dim $aArray[$width][$height] Dim $aArray[^ ERROR >Exit code: 1 Time: 2. #include <gdiplus.au3> #include <array.au3> #include <winapi.au3> $file=FileOpenDialog("Choose Your Image", @WorkingDir , "JPG (*.jpg)") Opt("MustDeclareVars", 0) _GDIPlus_Startup() Dim $pixelarray Local $file_in = $file ; "image1-before.jpg" ; Local $file_out ="test.jpg"; "image1-after.jpg" $save=FileOpen("information.txt",1) _FileImageToArray($file_in, $pixelarray) $x_size=UBound($pixelarray,1) $y_size=UBound($pixelarray,2) $x_size-=1 $y_size-=1 for $x=1 to $x_size for $y=1 to $y_size FileWrite($save,$pixelarray[$x][$y]) Next Next FileClose($save) FileCLose($file) ;FUNCTIONS ; code by Malkey: thanks man! Func _FileImageToArray($filename, ByRef $aArray) Local $Reslt, $stride, $format, $Scan0, $iW, $iH, $hImage Local $v_Buffer, $width, $height Local $i, $j $hImage = _GDIPlus_ImageLoadFromFile($filename) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") Dim $aArray[$width][$height] For $i = 0 To $iW - 1 For $j = 0 To $iH - 1 $v_Buffer = DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)) $aArray[$i][$j] = Hex(DllStructGetData($v_Buffer, 1), 8) Next Next _GDIPlus_BitmapUnlockBits($hImage, $Reslt) _GDIPlus_ImageDispose($hImage) Return EndFunc ;==>_FileImageToArray ; code by Malkey: thanks again ;) Func _FileArrayToImage($filename, $aArray) Local $iW = UBound($aArray, 1), $iH = UBound($aArray, 2), $sResult = "" Local $hBMP, $hImage1, $Reslt, $width, $height, $stride, $format, $Scan0 Local $sResult, $v_BufferA Local $i, $j $hBMP = _WinAPI_CreateBitmap($iW, $iH, 1, 32) $hImage1 = _GDIPlus_BitmapCreateFromHBITMAP($hBMP) $Reslt = _GDIPlus_BitmapLockBits($hImage1, 0, 0, $iW, $iH, $GDIP_ILMWRITE, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") $v_BufferA = DllStructCreate("DWORD[" & $height * $width & "]", $Scan0) For $j = 0 To $height - 1 For $i = 0 To $width - 1 DllStructSetData($v_BufferA, 1, Execute("0x" & $aArray[$i][$j]), ($j * $width) + $i + 1) ; "+1" - base 1. Next Next _GDIPlus_BitmapUnlockBits($hImage1, $Reslt) _GDIPlus_ImageSaveToFile($hImage1, $filename) _GDIPlus_ImageDispose($hImage1) _WinAPI_DeleteObject($hBMP) Return EndFunc ;==>_FileArrayToImage I can't seem to figure out my mistake Any Ideas?