Sign in to follow this  
Followers 0
Hasher

replacing value in array

7 posts in this topic

hi all

Having trouble with replacing a string in a dimensional array. basically i grab the first row in a Open office calc spreadsheet which are the column headers and want to change the names. I keep getting :

C:\Users\TurboLister\Packer.au3 (37) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

$array[1][5] = "TEST"

^ ERROR

Im sure Im doing something stupidly wrong here :-/

Thanks in Advance Paul

Global $array[1][30]
_OOInit()
_OOOpenBook(@ScriptDir & "/" & $file)
winwait("OpenOffice")
WinActivate("OpenOffice", "")
$array = _OOSheetRangetoArray(0, "A1", "AC1", "")
$array[1][5] = "TEST"
$OutString = StringReplace($string, $farray[$i][0], $farray[$i][1])
_ArrayDisplay($array, "Test")

Firefox's secret is the same as Jessica Simpson's: its effortless, glamorous style is the result of — shhh — extensions!

Share this post


Link to post
Share on other sites



Hasher,

What do you expect the value of $i to be?

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Actually the problem is that when you dimension an array with a dimension size of 1, the only valid value that subitem can have is $array[0], not $array[1].


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes, that would be problem #2 with this code...based on the error message

$array[1][5] = "TEST"

we are not seeing the code that produced the error.

kylomas

edit: assumption

of course I am assuming that $array[1][0] - [1][4] worked

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

first array row, 5-th column is $array[0][5]

$array[1][5] is the second row, 5-th column in the array

I recommend you use _ArrayDisplay($array) before trying to output data.


My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

BTW, kylomas you're also correct that his code in the line following the error line is also going to be causing him issues later because $i isn't defined anywhere in the snippet he showed us. I should have made note of that, but forgot to last night.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

BremanNH,

yea, I'm hanging up my fingers for now...I'm something like 4 for 7 correct in my last posts...if I was an Air Traffic Controlman there would be a lot of people in deep shit...

till head re-engages,

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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
Sign in to follow this  
Followers 0