[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] JScript help please.



PureBytes Links

Trading Reference Links

Hi,

I am trying to write a Jscript which will take the ticker from AFL; 
build the dataFile name from this variable inside script; open the 
file and read ins datas inside the file; It then returns datas from 
the file back into AFL variables.  However I got the Jscript errors 

Source: Microsoft JScript runtime error
Line:   88   Char:   1
Error:  0  -   File not found.

Can someone see if I have declared the file object correctly?

Here is the code.  TIA


currentTicker = Name();

<%
var ForReading = 1,ForWriting = 2, ForAppending = 8;
var fileSystemObj, tickerString, currentLine;
var wmp30Dir, currentFileName;

tickerString = AFL("currentTicker"); // GetArray ("Price") from AFL

winMidasDir = "C:\\wmp30\\";
fileSystemObj = new ActiveXObject("Scripting.FileSystemObject"); // 
creating an object type ActiveX
dataFilePtr = fileSystemObj.OpenTextFile (winMidasDir + tickerString 
+ "DAT", ForReading); // build datafile name

for ( i = 0; i < 11; i++ ) {
  currentLine = dataFilePtr.ReadLine();
  switch ( i ) {
    case 0:
	startOfBars = currentLine;
    case 1:
	S1LaunchDate = currentLine;
    case 2:
      	S2LaunchDate = currentLine;
    case 3:
      	S3LaunchDate = currentLine;
    case 4:
      	R5LaunchDate = currentLine;
    case 5:
      	R4LaunchDate = currentLine;
    case 6:
      	R3LaunchDate = currentLine;
    case 7:
	R2LaunchDate = currentLine;
    case 8:
	R1LaunchDate = currentLine;
    case 9:
      	TBLaunchDate = currentLine;
    case 10:
	TBCenterDate = currentLine;
    default:
	;
  } // end of switch.
}

dataFilePtr.Close();

AFL.Var("S1LaunchDate") = S1LaunchDate;
AFL.Var("S2LaunchDate") = S2LaunchDate;
AFL.Var("S3LaunchDate") = S3LaunchDate;
AFL.Var("R5LaunchDate") = R5LaunchDate;
AFL.Var("R4LaunchDate") = R4LaunchDate;
AFL.Var("R3LaunchDate") = R3LaunchDate;
AFL.Var("R2LaunchDate") = R2LaunchDate;
AFL.Var("R1LaunchDate") = R1LaunchDate;
AFL.Var("TBLaunchDate") = TBLaunchDate;
AFL.Var("TBCenterDate") = TBCenterDate;

%>



Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/