LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

WriteFile

I have a file from a file and then to the new data should save.
but strangely, no values written into the file, perhaps I can help someone
there are no errors at the compiling

Code


//HEADERFILE

#define LAST    10000
#define PATHLEN    256
tydef struct{
    int i16Step;
    int i16Fkt;
    int i16SCounter;
    double i32STimer;
    int i16ACounter;
    double i32Voltage;
    int i16TempO;
    int i16TempS;
    int i16Gas;
    int i16GasFlow;
}SETTINGS


tydef struct{
    double setStep;
    double setFkt;
    double setSCounter;
    double setSTimer;
    double setACounter;
    double setVoltage;
    double setTempO;
    double setTempS;
    double setGas;
    double setGasFlow;
}FILE



//SOURCEFILE
static SETTINGS Temp;
char tempFileName [PATHLEN];

SETTINGS LoadNext(unsigned int NEXT)
{
    char tmpFile[PATHLEN];
    char *ptrTmpName;
    static IniText file = 0;
    FILE StepTemp;
    int u8Err = 0;

    //save filename
    strcpy(tmpFile, "C:\\Dokumente und Einstellungen\\Admin\\Eigene Dateien\\CVI\\File.ini");

    //delete old file
    if(file)
    {
        Ini_Dispose(file);
        file = 0;
    }

    //create new file
    if (!(file=Ini_New(0)))
    {
        MessagePopup("Error");
        u8Err=1;
    }

    //read data
    if(Ini_ReadFromFile8file, tmpfile)
    {
        MessagePopup("Error: can not create a new file");
        u8Err=1;
    }
    else
    {
        //create a step
        ptrTmpName = StrDup("STEP_");
        sprintf(ptrTmpName, %s%d, ptrTmpName, NEXT);
        strcpy(tempFileName, ptrTmpName);

        if (0 >= Ini_GetInt(file, tempFileName, "Step", Temp.i16Step))
        {
            //is it the last step???
            if ( 0 == strcmp(tempFileName, "LAST"))
            {
                MessagePopup("Last Step");
                Temp.i16Step = LAST;
                Temp.i16Fkt = FKT_END;
            }
            else
            {
                MessagePopup(ptrTmpName, "Error");
                u8Err=1;
            }
        }
    }

    do{
        StepTemp.setStep = Temp.i16Step;
        StepTemp.setFkt = Temp.i16Fkt;
        StepTemp.setSCounter = Temp.i16SCounter;
        StepTemp.setSTimer = Temp.i32STimer;
        StepTemp.setACounter = Temp.i16ACounter;
        StepTemp.setVoltage = Temp.i32Voltage;
        StepTemp.setTempO = Temp.i16TempO;
        StepTemp.setTempS = Temp.i16TempS;
        StepTemp.setGas = Temp.i16Gas;
        StepTemp.setGasFlow = Temp.i16GasFlow;
    }
    while(strcmp(tempFileName, "LAST"));

    return (Temp);
}

//Write the file
void WriteFile()
{
    char tmpWrite[];
    static IniText tmpFileWrite;
    char *ptrName = 0;
    int u8Err = 0;
    static IniText writeFile = 0;

    //save filename
    strcpy(tmpWrite, "C:\\Dokumente und Einstellungen\\Admin\\Eigene Dateien\\CVI\\File.ini");

    //delete old file
    if(writeFile)
    {
        Ini_Dispose(writeFile);
        writeFile = 0;
    }

    //create new file
    if (!(writeFile=Ini_New(0)))
    {
        MessagePopup("Error");
        u8Err=1;
    }

    do{
        Ini_PutInt(tmpFileWrite, tempFileName,"Step", Temp.i16);
        //do it for all variables
    }
    while(strcmp(tmpFileWrite, "LAST"));

    Ini_WriteToFile(tmpFileWrite, tmpWrite);
}


0 Kudos
Message 1 of 6
(2,773 Views)
There sure is a lot of winking in that code.  I am not sure that I understand your problem entirely.  Would you be able to post an example of the code you have written so far, this may help us to understand where you are trying to get to.
0 Kudos
Message 2 of 6
(2,766 Views)
Where does LabVIEW fit into this question?
0 Kudos
Message 3 of 6
(2,755 Views)
Methinks ye be looking for the LabWindows board, matey. Arrr.
0 Kudos
Message 4 of 6
(2,749 Views)
Looks like LabWindows to me, too.  But if you redo it LabVIEW and still have problems, come back and tell us about it.
-Matt Bradley

************ kudos always appreciated, but only when deserved **************************




0 Kudos
Message 5 of 6
(2,734 Views)
Sorry. I'm new here and I've accidentally in the wrong forum posted
0 Kudos
Message 6 of 6
(2,698 Views)