Look in the editor's reference and search for FileIsLineEnding() and use the example reading a csv-file
gooly:
Look in the editor's reference and search for FileIsLineEnding() and use the example reading a csv-file
Look in the editor's reference and search for FileIsLineEnding() and use the example reading a csv-file
gooly:
Look in the editor's reference and search for FileIsLineEnding() and use the example reading a csv-file
Look in the editor's reference and search for FileIsLineEnding() and use the example reading a csv-file
Thanks for answering gooly.
I've tried it, but do not understand the logic , you could please show me how would a function
that takes an integer and reads the integer values received over the next two values ?
My Code;
void Sumoc(int TKC) { int a,b,c; string as,bs,cs; Print(" Tiket de compra =", TKC); HandleSumoC=FileOpen(ArquivoC,FILE_CSV|FILE_READ,";"); if(HandleSumoC<0) {Print("Erro ao tentar abrir o arquivo na função SumoC ",GetLastError());} else while(!FileIsEnding(HandleSumoC)) { as =FileReadString(HandleSumoC); bs =FileReadString(HandleSumoC); cs =FileReadString(HandleSumoC); if(FileIsEnding(HandleSumoC)==true)break; if(as==IntegerToString(TKC)) { a= StrToInteger(as); b= StrToInteger(bs); c= StrToInteger(cs); } Print("a b c e TKC=========================================================== ",a," ", b, " ",c," e TKC ",TKC); close_orders(a,b,c); FileClose(HandleSumoC); } }
Dom_Kissaba:
My Code;
FileClose(HandleSumoC);
FileClose() might be the culprit here; you might put it inside (or elsewhere)
if(FileIsEnding(HandleSumoC) ) /* please notice i am not puttin ==true on purpose */
or the file will close the very first time while is executed
Also, while i can not be sure, it looks to me that you actually want to put all following lines inside if
if(as==IntegerToString(TKC)) { a= StrToInteger(as); b= StrToInteger(bs); c= StrToInteger(cs); /* curly } not here */ Print("a b c e TKC=========================================================== ",a," ", b, " ",c," e TKC ",TKC); close_orders(a,b,c); } /* maybe here ( a guess ) */
best regards
forgiveness, really was wrong, I had changed the code later
It was so!
table for reading.
Code for read the table.
void Sumov(int TKC) { int a,b,c; string as,bs,cs; Print(" Primeiro Ticket ", TKC); //first ticket HandleSumoV=FileOpen(ArquivoV,FILE_CSV|FILE_READ,";"); if(HandleSumoV<0) {Print("Erro ao tentar abrir o arquivo na função SumoV ",GetLastError());} else while(!FileIsEnding(HandleSumoC)) { as =FileReadString(HandleSumoV); bs =FileReadString(HandleSumoV); cs =FileReadString(HandleSumoV); if(as==IntegerToString(TKC)) // if first ticket read { a= StrToInteger(as); //a=first ticket b= StrToInteger(bs); //b=second Ticket c= StrToInteger(cs); //c=third ticket FileClose(HandleSumoC); Print(" ordens que devem ser fechadas ", a," ",b," ",c); //orders to close } CLOSE_ORDERS(a,b,c); //function that takes the orders to be closed if(FileIsEnding(HandleSumoV)==true)break; } FileClose(HandleSumoV); FileFlush(HandleSumoV); }
The function works in the first loops but then begins to error.
printed numbers.
a b c
1 | 22 | 23 |
2 | 32 | 33 |
35 | 36 | 37 |
31 | 0 | 0 |
0 | 0 | 0 |
0 | 0 | 0 |
Very thanks for answering Gooly. I will try this
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello friends, I am confused by reading files in CSV .
I created a file and can not write him the ticket orders to be closed in the future, but my problem is time to read these tickets.
I used a function that receives a ticket, and then reads both tickets of the next column, and then sends the three tickets line to another function to close the orders.
for example:
If (ticket == 63) {A = 63, B = 64, C = 65}
If (ticket == 67) {A = 67, B = 68, C = 69}
and so on.
The problem is that the my function only reads the first line of the file.
Someone PLEASE help me?
I've tried several ways, but I can not understand the operation of the pointer when you want to read the CSV data.
(I did not find enough examples to understand the reading files)