PureBytes Links
Trading Reference Links
|
Hey Mike (or anyone),
As a simple test, I am first trying to extract a few numbers from a basic text file and print them to the interpretation window. But I'm getting weird results. My code looks right, as far as I can tell. The text file is simply the numbers 1 thru 12, each on a line, like so:
1 2 3 4 5 6 7 8 9 10 11 12
I stuck the text file in my route directory, C:\
Here is the AFL:
count = 0; fh = fopen("c:\\TestExtractFile.txt", "r");
if (fh) { while(!feof(fh)) { good[count++] = StrToNum(fgets(fh)); printf("Number: %gn", good[count++] ); } } else { printf("ERROR: file can not be found (does not exist)"); }
But this is the weird output I get:
Number: 5.30979e-037nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0nNumber: 0n
Any idea what I'm doing wrong?
--- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@xxx> wrote: > > Thanks Mike! I was dealing with the latter case. So your file > operations code looks like it might do the trick. > > I will test this out. > > > --- In amibroker@xxxxxxxxxxxxxxx, "Mike" sfclimbers@ wrote: > > > > You are presumably generating the "stuff" code somewhere, right? > > > > e.g. > > condition65 = ...stuff; > > condition126 = ...stuff; > > > > Thus, they are simply suggesting that you additionally generate the > > population of the array at the same time. > > > > e.g > > count = 0; > > > > condition65 = ...stuff; > > good[count++] = 65; > > > > condition126 = ...stuff; > > good[count++] = 126; > > > > Now, when constructing your dynamic variable, iterate through the > > array values something like this (untested): > > > > index = Optimize("Index", 0, 0, count - 1, 1); > > > > Buy = VarGet("condition" + good[index]); > > Sell = ... > > > > If that is not the case, and your conditions are already in the same > > AFL as your Buy statement, and the DLL just spits out numbers to a > > file. Then add file operations to populate the good array (untested). > > > > count = 0; > > fh = fopen("good.txt", "r"); // From DLL, single number per line > > > > if (fh) { > > while(!feof(fh)) { > > good[count++] = fgets(fh); // May need to convert to number? > > } > > } else { > > printf("ERROR: file can not be found (does not exist)"); > > } > > > > index = Optimize("Index", 0, 0, count - 1, 1); > > > > Buy = VarGet("condition" + good[index]); > > Sell = ... > > > > Mike > > > > --- In amibroker@xxxxxxxxxxxxxxx, "ozzyapeman" <zoopfree@> wrote: > > > > > > When you say include file, does that only encompass other AFLs? Or > > > could it also include a generic csv file? > > > > > > If it is only other AFLs, which it appears to be from the online > > > index, then won't I still have to hand set each variable to an > > array? > > > Or can I just make the file a range of numbers like: > > > > > > 65 > > > 126 > > > 867 > > > 1023 > > > etc... > > > > > > Also, the online index says that using include can dramatically slow > > > down AFL, even for a single instance. Is that still the case, or is > > > that based on earlier AmiBroker version performance? > > > > > > http://www.amibroker.com/guide/afl/afl_view.php?name=%23include > > > > > > Thanks for any input. > > > > > >
__._,_.___
**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.
*********************
TO GET TECHNICAL 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
*********************************
__,_._,___
|