LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

d

darnell, there is a lot of confusion in what you posted!

 

Here some points that came to my mind while reading your posts.

 

First of all, when you think to post someting... stay calm, relax, carefully think to what you are doing... next post one message only with the result of all checks and corrections ! Smiley Wink

Following is a small table with the result of Ini_GetStringIntoBuffer in various conditions:

 

If the inifile is this one: You will get these results:
------------------------------- ----------------------------------------------
OperatorID = "Unknown" error = 1, g_sOperatorID = "Unknown"
OperatorID = "" error = 1, g_sOperatorID = ""
OperatorID = error = 0, g_sOperatorID = ""
(no OperatorID item) error = 0, g_sOperatorID = ""

 

 

I have noticed that previously you were reading the three values with different variables passed in Section Name parameter: this can lead to unpredictable results is the names stored in the variables were different. Now that you are writing and reading to/from the same section you are likely to have solved your problems, aren't you?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 51 of 63
(1,378 Views)

so are you suggesting change the names in one of the function calls, so less confustion, and really dont make no since to overwrite them , only thing I need to overwrite

in my code is my offset x and y values so that I can remember where im located when from the current position.

 

next question when i step through the first error it gives me a value of 1 which is correct, because file actually exists on disk.

but when i step through the Ini_ReadFromfile , the error value you is 0 why is that, when the file exist, im a little confuse on this one 

 

error=FileExists(sIniFilePathName,0);
    if(error<=VI_SUCCESS)
    { 
        //Terminate DAS3000.exe
        Terminate_Executable();
        goto Error;

    }
    errChk(Ini_ReadFromFile (IniTextFileHandle,sIniFilePathName));
    if(error <= 0)
    {
        error = ToolErr_ErrorReadingFile;      // defined in toolbox.h
        goto Error;
    }
   
 

 

 

 

0 Kudos
Message 52 of 63
(1,377 Views)

Here the help on return code from FileExists:

Returns 1 (TRUE) if the file exists.

Returns 0 (FALSE) if the file was not found.

Returns a negative User Interface Library error code if an error occurred.

 

Here the help from Ini_ReadFromFile:

Indicates wether the function was successful.

 

A zero indicates success.

 

A negative error indicates an error.

(Bold highlight is mine)

 

 

I'm a little bit tired to waste my time pasting here some informations you have at hand simply pressing F1. Smiley Mad

 

PLEASE READ THE DOCUMENTATION ON THE FUNCTIONS YOU ARE USING BEFORE ASKING QUESTIONS!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 53 of 63
(1,377 Views)

darnell,

 

Are you aware that it has been 52 posts in this thread (whose subject means nothing) and yet you are struggling with the return values from the first post.

There has been almost no progress both in the subject and in your behaviour.

 

You are doing no reading at all, yet you still expect us to read your messy and untested code with each message you post.

 

All functions of NI state clearly what is returned in which situation.

All you have to is to READ before you WRITE!

S. Eren BALCI
IMESTEK
0 Kudos
Message 54 of 63
(1,373 Views)

yea im mad at my self , for that one, yea u think im getting sleepy, thats what is, like I you said just relax.

 

okay this should be last email for tonite. 3 questions and then im out of your way. 

 

 

1. question in the toolbox.h file the is enum  with all the errors which is ToolError, is there a way to where it can automatic generate

    the error instead of me storing the error in the error variable like this         error = ToolErr_MissingItem; is there away to avoid that.

    like GetRS232ErrorString gives you all the errors  without putting the error into a variable. is there away to Get ToolError ?

 

 

2. I still want to use this logic below, but its going to put the string unknown in the variables when there is a error which is cool.

    but when I jump down to this line below error is going to be 1 because it actualy got a string which is unknown.

    how can i do the check for the unknown string after calling the Ini_PutString. i want to do sometype of check wherein if the  g_sOperatorID=="unknown"then fail etc.....

 

    //Storing the operator Id and seeker serial number in a text file
    //along with x and y offset position
    errChk(Ini_PutString(IniTextFileHandle, g_sSkrSerialNumberk, "OperatorID",
              g_sOperatorID));
    if(error <= VI_SUCCESS)
    {
       error = ToolErr_MissingItem;
       goto Error;
    }
*************************************************************************************************

 

 

 

    // Get operator ID
    if((texGetTPC ("OperatorID" ,g_sOperatorID,40))== FALSE)
    {
        //Try again
        /*if( (texGetTPC ("OperatorID",g_sOperatorID, 40)) == FALSE )
        {
            sprintf( szStringk,
                     "texGetTPC error - Skr Serial "
                     "Number cannot be retrieved '%s'",
                     g_sOperatorID );
            LOG_FILE( szStringk );
            strcpy( g_sOperatorID, "Unknown");
            LOG_FILE(g_sOperatorID);
        } */
    }
   
    // Get UUT serial number
    if((texGetTPC ("UUTMSN" ,g_sSkrSerialNumberk,40))== FALSE)
    {
        //Try Again
        /*if( (texGetTPC (UUT_MSN,g_sSkrSerialNumberk, 40)) == FALSE )
        {
            sprintf( szStringk,
                     "texGetTPC error - Skr Serial "
                     "Number cannot be retrieved '%s'",
                     g_sSkrSerialNumberk );
            LOG_FILE( szStringk );
            strcpy( g_sSkrSerialNumberk, "Unknown");
        } */
    }
 

3. does this make sense to do return Failure if im doing the exit(0); 

 

    else if(!strcmp(sFunction,"BORESIGHT"))                                            
    {
            if((iErrorFlag = Boresight_Command(&dAZposX,&dELposY))< SUCCESS)
            {
                ERRPRINT("Error retrieving offset position.");
                LOG_FILE("Error retrieving offset position.");
                MessagePopup("Error Message","Error setting FILE name.");
                exit(0);
                return FAILURE;
            }
    }
 

0 Kudos
Message 55 of 63
(1,372 Views)

I decided to just handle the unknown string in this if statement, that way the program will end if jumps into the loop, what do you think?

 

 

   // Get operator ID
    if((texGetTPC ("OperatorID" ,g_sOperatorID,40))== FALSE)
    {
        //Try again
        if( (texGetTPC ("OperatorID",g_sOperatorID, 40)) == FALSE )
        {
            sprintf( szStringk,
                     "texGetTPC error - Skr Serial "
                     "Number cannot be retrieved '%s'",
                     g_sOperatorID );
            LOG_FILE( szStringk );
            strcpy( g_sOperatorID, "Unknown");
            LOG_FILE(g_sOperatorID);
            if(g_sOperatorID==g_sOperatorID)
            {
                MessagePopup("Error Message","Operator is Unknown");
                exit(0);
            }
        }
    }
   

0 Kudos
Message 56 of 63
(1,367 Views)

darnell wrote: 

1. question in the toolbox.h file the is enum  with all the errors which is ToolError, is there a way to where it can automatic generate

    the error instead of me storing the error in the error variable like this         error = ToolErr_MissingItem; is there away to avoid that.

    like GetRS232ErrorString gives you all the errors  without putting the error into a variable. is there away to Get ToolError ? 


No way.

But you should note the difference between ToolErr_MissingItem, which is an integer value, and GetRS232ErrorString, which is a function returning a string based of a value it receives.

 

 


darnell wrote: 

2. I still want to use this logic below, but its going to put the string unknown in the variables when there is a error which is cool.

    but when I jump down to this line below error is going to be 1 because it actualy got a string which is unknown.

    how can i do the check for the unknown string after calling the Ini_PutString. i want to do sometype of check wherein if the  g_sOperatorID=="unknown"then fail etc.....



You can add a check based on strcmp () function. You should have no difficulty in implementing it.

 

 


darnell wrote: 

3. does this make sense to do return Failure if im doing the exit(0); 

 

    else if(!strcmp(sFunction,"BORESIGHT"))                                            
    {
            if((iErrorFlag = Boresight_Command(&dAZposX,&dELposY))< SUCCESS)
            {
                ERRPRINT("Error retrieving offset position.");
                LOG_FILE("Error retrieving offset position.");
                MessagePopup("Error Message","Error setting FILE name.");
                exit(0);
                return FAILURE;
            }
    }
 


I personally prefere not to use exit (). I return an error code from the functions and leave the caller decide wether to continue or not. I f the caller (or your function, if you want to do so) wants to terminate the program I call QuitUserInterface to jump to the main () which executes instructions immediately following RunUserInterface (), (were I have placed all cleaning of resources, closing of files and ports and so on) and then terminates the program.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 57 of 63
(1,367 Views)

if im going to use quituserInterface(0); do i really need to a return failure. or its best to keep from for a maintenance programmer?

 

 

            //Sets the file location where the real time video capture
            //is going to be stored on disk
            if((iErrorFlag = Set_File(sCommand))< VI_SUCCESS)
            {
                const char *sErrorSettingFileName="Error setting FILE name.";
                ERRPRINT(sErrorSettingFileName);
                LOG_FILE(sErrorSettingFileName);
                MessagePopup("Error Message",sErrorSettingFileName);
                QuitUserInterface(0);
                return FAILURE;
            }
 

0 Kudos
Message 58 of 63
(1,341 Views)

It seems to me that we are running into a completely different argument: you should open a new thread for that (possibly with a meaningful title).

 

Anyway, what's that return FAILURE for?

Usually return values from a function are intended for the caller to do something based on them.

If you terminate the program, returning FAILURE, SUCCESS, PI, your telephone number or whatever else from the callback has no meaning!



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 59 of 63
(1,330 Views)

You probably know that already, but maybe you don't. 

The value you put into the QuitUserInterface function is actually passed as the return value of RunUserInterface.

 

void main(void)

{

  int r; 

  ...

  r = RunUserInterface();

  ... 

}

 

int CVICALLBACK QuitProgram (...) 

{

  ...

  QuitUserInterface(3);

  ... 

}

 

So, here the variable r gets the value of 3 after the QuitUserInterface call.

You may use the functionality for your purposes. 

S. Eren BALCI
IMESTEK
Message 60 of 63
(1,320 Views)