Here is my finish result.
With The proposed code by John, BowlesJ3 and the information given by TJ I'm now able to
- Read a text file
- Place all information from the text file in an appropriate Variable
With the original code, I was able to read string only. Numbers in the string caused a failure in the routine. To resolved it, In my text file, I added a characters in front of any numbers to mystify the code. From the new string i them removed the added characters to get a clean numbers value
Original text file value
True,EUR.USD,Buy Stop,3700,1.4367,Stop Loss,1.4345
New Text File Value ( " ! " was added in front of numbers
True,EUR.USD,Buy Stop,!3700,!1.4367,Stop Loss,!1.4345
To test it:
1) create a text file containing the new text value. My actual one is called CXVData.txt
2) replace the file adress by yours in this line
Value1 = ListC.ReadFile(ListC_ID,"f:\temp\TestData\CSVData.Txt");
Code: Select all
Variable:
TargetTime (0),
Delay (500),
MyBigString ("True,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345,!"),
String2 (""),
StoreValue (0),
MyStringLoc (1),
Price (1.4635),
TextFile (""),
ListC_ID(0),
DataReadyString (""),
DataReady (False),
QTYString (""),
QTY (0),
MarketName (""),
OrdersToDo (""),
OrderEntryPriceString (""),
OrderEntryPrice (0),
OrderStopToDo (""),
OrderStoLossPriceString (""),
OrderStopLossPrice (0),
LISTDataReadyString_ID (0),
ListQTY_ID (0),
ListMarketName_ID (0),
ListOrdersToDo_ID (0),
ListOrderEntryPrice_ID (0),
ListOrderStopToDo_ID (0),
ListOrderStoLossPrice_ID (0),
ValidData (False);
Array: OrdersLine[7]("");
//----------------------------------------------------------------------------------------------
// Code Start here
//("True,EUR.USD,Buy Stop,37000,1.4367,Stop Loss, 1.4345,!"),
//Read the CSVData and separate the value
Listc_ID =ListC.New;
Value1 = ListC.ReadFile(ListC_ID,"f:\temp\TestData\CSVData.Txt");
LISTDataReadyString_ID = ListC.Get(ListC_ID,1);
ListMarketName_ID = ListC.Get(ListC_ID,2);
ListOrdersToDo_ID = ListC.Get(ListC_ID,3);
ListQTY_ID = ListC.Get(ListC_ID,4);
ListOrderEntryPrice_ID = ListC.Get(ListC_ID,5);
ListOrderStopToDo_ID = ListC.Get(ListC_ID,6);
ListOrderStoLossPrice_ID = ListC.Get(ListC_ID,7);
//Get the data now
DataReadyString = ListS.Get(LISTDataReadyString_ID ,1);
MarketName = ListS.Get(ListMarketName_ID ,1);
OrdersToDo = ListS.Get(ListOrdersToDo_ID ,1);
QTYString = ListS.Get(ListQTY_ID ,1);
OrderEntryPriceString = ListS.Get(ListOrderEntryPrice_ID ,1);
OrderStopToDo =ListS.Get(ListOrderStopToDo_ID ,1);
OrderStoLossPriceString =ListS.Get(ListOrderStoLossPrice_ID ,1);
// Replace String in the proper format for the needed one
QTY = StrtoNum(midstr(QtyString,2,StrLen(QTYString)-1));
OrderEntryPrice = StrtoNum(midstr(OrderEntryPriceString,2,StrLen(OrderEntryPriceString)-1));
OrderStopLossPrice = StrtoNum(midstr(OrderStoLossPriceString,2,StrLen(OrderStoLossPriceString)-1));
If instr(DataReadyString, "True") >= 1 then DataReady = True else DataReady = False;
If barnumber = 1 then print (
DataReady," ",
MarKetName," ",
OrdersToDo, " ",
Qty:0:0, " ",
OrderEntryPrice:4:4, " ",
OrderStopToDo, " ",
OrderStopLossPrice:4:4);
I'm not an expert with ListC.readfile and others ElCollections DLL. bowlesJ3 is the one. I just copied and adapted is work
Martin