Jump to content

Recommended Posts

Posted

When I try to execute the code below when compiled thru VBA (shell command) or theu a file:// url from brower I get..

Line -1:

Error: Array variable subscript badly formatted

It works fine thru Scite or with a doubleclick on the exe or theu the Start/Run.

TIA, Dennis

Here is what is in list.dlm: (following 2 lines)

ORCL,FISV,BKC,MO,SYY,KR,RSH

8

include <Excel.au3>

Dim $ini = 'list.dlm'
$source = @WorkingDir & "\oracleFisv"
FileDelete($source)

$list = FileReadLine($ini, 1)
$n = FileReadLine($ini, 2)

Dim $symbol[$n]

InetGet("http://finance.yahoo.com/q?s=" & $list & "&d=s", $source, 1)
$txt = FileRead($source)
$oExcel = _ExcelBookAttach("dlx.xls", "FileName")
Dim $row = 3, $col = 16
For $i = 0 To $n - 1
    $a = StringMid($txt,StringInStr($txt,"yfs_l10",0,$i) + 10, 15)
    $symbol[$i] = StringRegExpReplace($a,"[^0-9.]","")
    _ExcelWriteCell($oExcel, $symbol[$i], $row, $col)
    $row = $row + 1
Next
Posted (edited)

Thank you Zedna. Worked great!

I dont understand why that caused the 'array' error tho.

Dennis

Dim $ini = 'list.dlm'
$n = FileReadLine($ini, 2)
Dim $symbol[$n]

FileReadLine() doesn't find file (in working directory here) so $n is probably zero or empty string 

and then Dim $symbol[0] or Dim $symbol[""] is incorrect

You can avoid such problems by using If @error then ... at places where you could expect problems here after FileReadLine().

Edited by Zedna

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
×
×
  • Create New...