Jump to content

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.


Recommended Posts

Hello.

I have a script that gives this error.

[color=#616375][font=Helvetica, Verdana][size=3][background=rgb(250, 247, 244)]Line 6918 (File"C:\program files (x86)\Steam\Steamapps\common\rome total war gold\launcher\Rome Total Ralism VII.exe"):[/background][/size][/font][/color]

[color=#616375][font=Helvetica, Verdana][size=3][background=rgb(250, 247, 244)]Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.[/background][/size][/font][/color]

The problem is that only a few people have this error. (I don't, so I can't reproduce it)

Also, it's with the compiled exe, so I believe the line number gives refers to that, and not the source code. (My script only has around 700 lines.)

Is there something I can do to debug it?

The error deals with array, so I have checked them, but could see nothing wrong. What should I look for in particular for this kind of error?

Thanks. :)

Link to comment
Share on other sites

You have an array in your script (e.g. $Array[10] with 10 elements). As the numbering starts with 0 you have to access them from $Array[0] to $Array[9]. If you try $Array[10] you will see the mentioned error.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

It gives the correct line, however when you compile your script you merge all files into one, with includes being at the top, and yours at the bottom. You can calculate the line by adding includes etc. If you used obfuscator, you also wanna factor in that it could replace constants.

Ever wanted to call functions in another process? ProcessCall UDFConsole stuff: Console UDFC Preprocessor for AutoIt OMG

Link to comment
Share on other sites

Not 100% true. Comments will be removed even when obfuscator is not used.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I had checked for that.

However, I have something like that.

Global $EntriesLine[999]
_FileReadToArray("..FOE.svnentries", $EntriesLine)
$CurrentRevision = $EntriesLine[4]

Could it give that kind of error if there more than 999 lines?

It shouldn't be more than ~400 lines long, but I guess writing something like that would be safer.

Global $EntriesLine
_FileReadToArray("..FOE.svnentries", $EntriesLine)
$CurrentRevision = $EntriesLine[4]

@Shaggi, thanks, I'll count.

Edited by Paedric
Link to comment
Share on other sites

_FileReadToArray sizes the array to its needs. But how do you access the elements of the array? Can you post this code snippet?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Only with the third line, that's it.

$CurrentRevision = $EntriesLine[4]

Could it be that there isn't enough lines though? If the file is empty, would it do that kind of error.

The only other thing that use an array is this.

Func _Start_steam($mod)
$SteamPath = RegRead("HKEY_LOCAL_MACHINESOFTWAREWow6432NodeValveSteam", "InstallPath")
If Not @error = 0 Then
MsgBox(0, "Steam Launcher - Error", "Failed to find Steam." & @CRLF & "Are you sure you have to use Steam in order to play Rome Total War?")
Else

Global $SteamBatchFileContent[13] ; 12 strings and 0 not used

Global $SteamUserName = IniRead(@ScriptDir & "" & $iniFile, $defaultIniSection, $UserNameIniKey, "")



$SteamBatchFileContent[1] = "set SteamAppId=4760"
$SteamBatchFileContent[2] = "set SteamAppUser=" & StringLower($SteamUserName)
$SteamBatchFileContent[3] = "set SteamAppVersionId=0"
$SteamBatchFileContent[4] = "set SteamPath=" & $SteamPath
$SteamBatchFileContent[5] = "set SteamUser=" & StringLower($SteamUserName)
$SteamBatchFileContent[6] = "set suppress_restart=1"
$SteamBatchFileContent[7] = "set ValvePlatformMutex=" & $SteamPath & "steam.exe"
$SteamBatchFileContent[8] = "set __STEAM_BOOTSTRAPPER_ICON_ID__=128"
$SteamBatchFileContent[9] = ""
$SteamBatchFileContent[10] = "set PATH=%SteamPath%;%PATH%"
$SteamBatchFileContent[11] = ""
$SteamBatchFileContent[12] = @ComSpec & " /c " & "start /affinity 1 /high " & "RomeTW-BI.exe" & $mod & " " & $cmdLineParams


; Delete any existing batch file and wait until it's gone.
If FileExists($SteamBatchFilePath) = 1 Then FileDelete($SteamBatchFilePath)

Sleep(250)

Local $Stop = 1
Do
$Stop = FileExists($SteamBatchFilePath)
Until $Stop = 0

; Create the batch file and wait until it's finished.
_FileWriteFromArray($SteamBatchFilePath, $SteamBatchFileContent)

Local $Stop = 0
Do
$Stop = FileExists($SteamBatchFilePath)
Until $Stop = 1

EndIf

If Run($SteamBatchFilePath) = 0 Then
MsgBox(0, "Steam Launcher - Error", "Failed to run SteamLauncher.bat.")
EndIf

EndFunc ;==>_Start_steam
Edited by Paedric
Link to comment
Share on other sites

  • Moderators

Paedric,

This looks to me very much like a script to launch the Rome Total War game on Steam. Have you read the Forum Rules? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Indeed, this is a mod launcher for Rome Total War.

The mod in question is RTRVII (http://www.twcenter.net/forums/forumdisplay.php?f=26), though I have created one for Roma Surrectum II(http://www.twcenter.net/forums/forumdisplay.php?f=251) which is quite similar.

If I read the rules correctly, what is banned is bot and other illegals thing.

The launcher simply start the game with the correct arguments, so users don't have to create a new shortcut each time.

Mods in RTW can be launched by adding -mod:my_mod_folder in the target of the shortcut, the script does that automatically, in this case for Steam.

I wasn't aware that it was something that was banned on those forums, but if it is an issue, you can close/delete this thread.

If you want to check it, I can also give you the whole source file.

Sorry for the troubles.

Link to comment
Share on other sites

  • Moderators

Peadric,

If I read the rules correctly, what is banned is bot and other illegals thing

It seems you did not read them very well: ;)

"Any discussion of using AutoIt to launch or interact with a game or game server violates our rules

So I am afraid that your script does fall into the prohibited category and this thread will now be locked. :naughty:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...