The problem I am having is trying to use the ReadFileLine twice in the same program.
This is what my RECIPES.CSV file looks like:
0,ROT2.500.145,2.500,.145,2.756
How Do I pull the ROT2.500 using the ReadFileLine?
[SAVE CODE]
int hfile; //file opened index
int i; //array scanning index
//cstring RecipeName;
// Create a new folder if it doesn't exist
CreateDirectory("/recipes");
//Create the file if it doesn't exist
CreateFile("/recipes/recipe.csv");
//open the file
hfile= OpenFile("/recipes/recipe.csv",1);
//Write each recipe as a line in the file
//Copy each array index as a file line beginning by the recipe index
for (i=0;i<1;i++)
{
WriteFileLine(hfile,RecipeName);
WriteFileLine(hfile,AsText(i)+","
+OutsideDiameter.AsText+","
+WallThickness.AsText+","
+GapRoll1.AsText);
}
//Close the file
CloseFile(hfile);
[/SAVE CODE]
****************************************************************************
[RETRIEVE CODE]
int i, hfile; //Declaration of Variables
cstring CurrentLineStored; //Declaration of Variables
i = 0; //Initialization of Variable (assume at this time that hfile = null
hfile = OpenFile("/RECIPES/RECIPE.CSV",0); //hfile is initialized in this step. The hfile pointer
// is essentially an alias or shorthand so that we don't have to type the function and file paths.
CurrentLineStored = ReadFileLine(hfile);//The CurrentLine stored in this small program is the hfile's
//line zero. The ReadFileLine function will automatically index itself every time it is called.
while(CurrentLineStored !="") // loop until all lines are read
{
//RecipeName:=ReadFileLine(hfile);
OutsideDiameter:=TextToFloat(Mid(CurrentLineStored,15,5));
WallThickness:=TextToFloat(Mid(CurrentLineStored,21,5));
GapRoll1:=TextToFloat(Mid(CurrentLineStored,27,5));
CurrentLineStored := ReadFileLine(hfile);
}
CloseFile(hfile);
//Do this at after a OpenFile or the program will hangup and the display will need
//physically reset.
[/RETRIEVE CODE]