Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.
Get Started

Asked
Resolved Resolved by ptp!

Filereadline Getting Error Data Is In Wrong Format

I have created a file by downloading data from the web.

this is the line of code

FileWrite($DataFile,HTTPGet($url1))

Where $DataFile is the file location on my harddrive and url1 is the where the data is on the web.

The data gets successfully wrote to the hard drive. 

Now my next line of code is $line = FileReadLine($DataFile). 

The first line of the Data file is:  <!DOCTYPE html>

This fails with the error Input string was not in a correct format.  

Now this used to work but with ARC this fails.

What format should the Datafile be in for this to continue?


Related Hardware EZ-Robot EZ-B v4
AI Support Bot
Related Content
Synthiam
Synthiam
#29  
Because there is no write. It's append. Appending just keeps appending to an existing file or creates a new one. There's no reason to keep a file open for appending. The only point to keeping the file open for reading is to know the position.

I've added two new methods for getting the current read position and getting the file length. It'll be in today's release.
#30  

Code:

File.appendStringLine
This commands locks the file and does not release the file. Is that an expected behavior ?
#31   — Edited
@dbeard:

User-inserted image


Example to capture the red part 

The forum break's the JavaScript code, posted code picture:

User-inserted image

 
@DJ 
Please read my previous post!
#32  
Here is my program for getting dow jones data.  I know it is a mess, but it works.

Code:

var url1 = "http://www.marketwatch.com/tools/marketsummary/indices/indices.asp?indexid=1&groupid=37";

print("Downloading Data");
var content = Net.hTTPGet(url1);

print("Content length=" + content.length);

print("Dow Jones Information Found:");

pos = 0;
do
{
//This method returns -1 if the value to search for never occurs.
var pos = content.indexOf("/investing/index/djia", pos);

if (pos>=0)
{
beginPos = pos

//search for a double quote after finding the begin string
pos = content.indexOf("\"", beginPos);
if (pos>0)
{
endPos = pos;
var link = content.substring(beginPos, endPos);
var volume = content.substring(endPos+144, endPos+153);
var tradedate = content.substring(endPos+193, endPos+205);
var tradetime = content.substring(endPos+245, endPos+255);
var amount = content.substring(endPos+297, endPos+309);
var tradepercent = content.substring(endPos+352, endPos+361);

place = 0
var startplace = volume.indexOf(">",place);
var endplace = volume.indexOf("<", place);
var fvolume = volume.substr(startplace+1, endplace-1);

place = 0
var startplace = tradedate.indexOf(">",place);
var endplace = tradedate.indexOf("<", place);
var ftdate = tradedate.substr(startplace+1, endplace-1);

place = 0
var startplace = tradetime.indexOf(">",place);
var endplace = tradetime.indexOf("<", place);
var fttime = tradetime.substr(startplace+1, endplace-1);

place = 0
var startplace = amount.indexOf(">",place);
var endplace = amount.indexOf("<", place);
var famount = amount.substr(startplace+1, endplace-1);

place = 0
var startplace = tradepercent.indexOf(">",place);
var endplace = tradepercent.indexOf("<", place);
var ftpercent = tradepercent.substr(startplace+1, endplace-1);

print("Date: " +ftdate);
print("Time: " +fttime);
print("Volume: "+fvolume);
print("Amount: "+famount);
print("Percent: "+ftpercent);

halt();
}
}
}
while(pos>=0);
#34  
Thanks everyone for the help.