Ed,
When you use text files (as in AFL), I beleive you
can not change contents. You can just add lines. (You might try replacing the
line with a blank and then re-write with desired contents - but am not
sure)
Suggest you change the format and add a correction
to the existing line. This is possible as long as you have not closed the file
or added a carriage return.
The new line could look like this:
SELL, 100, CHRW, STK, SMART, LMT, 52.44,
1,80,
where you have ordered 100 shares and got filled on
80.
This would require to write each line in 2 write
operations
For statistical info this might be better, so you
know how often you get partial fills.
Ara
----- Original Message -----
Sent: Tuesday, June 12, 2007 5:38
AM
Subject: Re: [amibroker] fopen
read/write
hi Joe,
thanks for your reply. I have a basketfile with
lines like:
SELL, 100, CHRW, STK, SMART, LMT, 52.44,
1,
a whole bunch of lines like this one above I send
to the TWS. I wrote some code that checks if the number of shares correspond
to the number of shares I have in my portfolio at IB.
So I want to be able to look at the number 100 in
this example, compare it to the real number of shares I have and then adjust
the number 100 if necessary. I know I could open a second file and use
it to write to. I however want to use the same file and change a number
in that file if necessary. In C or C++ or any other language this is possible.
Since AFL uses more or less the C syntax I wondered if we could do this in AFL
as well,
rgds, Ed
----- Original Message -----
Sent: Tuesday, June 12, 2007 2:19
PM
Subject: Re: [amibroker] fopen
read/write
Ed, as I read your question literally, YES, one can
read, write and append to a file. Like so from the Users
Guide.
Simultaneously - NO. Programs including
AFL are serial.
Now if you mean you want to change some
elements or fields in that file, you'll have to read in the record of that file, change the field and write the
record back out.
HTH Joe
>>>
fputs( string, filehandle ) RETURNS
NOTHING FUNCTION Writes (puts) the string to the file.
The filehandle must be a number returned by fopen function used to open
the file. The file has to be open for writing or appending ("w" or "a")
for this fputs to work.
----- Original Message -----
Sent: Tuesday, June 12, 2007 6:26
AM
Subject: [amibroker] fopen
read/write
hi,
anyone know if one can read + write to a
file. I need to read a file and change some numbers if necessary. Seems
that AFL can only read or write or append. In C or C++ it is possible
simultaneously. Anyone know how to do it in AFL?
thanks, Ed
__._,_.___
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
__,_._,___
|