LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

SriptFile Logic help

Hi I just need help with my logic for a two step process.

 

the first step to process is complete. which is writing my centroid point to a text file.

 

the second process I need a lil assistance taking the centriod point I just wrote and send it to back to any particular function I choose.

 

I just need a lil assistance for the second process. which is getting the x, y value back out and just sending it out to a particular function.

 

in the script file you see a BORESIGHT_READ , sets the centoid pixel range so thats the easy part, which i know how to do.

 

the BORESIGHT_WRITE is the actual centroid point that I have to send out to a particular function or write back out from the text file that Im posting.

 

I just need a Logic that i can follow if this is not already done.

 

 

 

Download All
0 Kudos
Message 1 of 33
(4,578 Views)

Darnell:

 

Our firewall doesn't let me download .scr files (thinking they might be potentially harmful scripts).  Can you repost them as .txt files?

 

What is the format of the data in your text data file?

Can you post a sample line from your text file?

 

The logic is the following:

Open the text file for reading.

Read a line of text.

Parse the data from the line of text.

Pass the data to the function that will use it.

...

Close the text file.

 

Depending on the format of your data, you may be able to read the line of text and parse the data in one step using a ANSI C library function like fscanf().

 

Message 2 of 33
(4,565 Views)

this is the text file,  if you cant downwload it, open the text file or ini file in notepad.

 

in the text file you will see x=320, and y=240.

 

I will take a and centroid value and subtract it from  the x and y value which is going to be the offset.

 

 

basically i want to write a centroid point to the ini file or text file.

 

 

then afterwards im going to grab the height and width and subtract it from the config file to get a offset.

 

once i get the offset x and y, send those values to  the other text file which is offset.txt  file.   

 

then im going to grab the offset value from the text file and send it to anytype of function that i please.

 

 

Download All
0 Kudos
Message 3 of 33
(4,557 Views)
CVI ships with an example project (ini.cws) that shows how to read and write ini files.  You'll see how to use section names and item names, and how to retrieve or manipulate item values.  Take a look at that.
Message 4 of 33
(4,574 Views)

  I know how to do it using the GetPrivateProfileString(); in windows,im trying to learn how to do it with cvi inifile.fp

 

  i havent got it work yet with inifile.fp functions

 

 

 
   char iniFile[MAX_PATHNAME_LEN];                             
   char iniFilePath[MAX_PATHNAME_LEN]={"C:\\Documents and Settings\\z1083774\\Desktop\\config file"};
   char sSection[][30] ={0};                                     
   char sTag[][30] = {"frameWidth",
                                "frameHeight"}; 
   char                        statPathName[MAX_PATHNAME_LEN] = "";    ///< Pathname for the station INI file.

   HRESULT     hr;
   IniText                     iniStation = 0;                         ///< Handle for the Station INI file.

       char    section[80];

 

   int frameWidth=320;

   int frameHeight=240;


    // Load the station information file
    Ini_Dispose( iniStation );
    iniStation = Ini_New( 0 );
    strcpy( section, "DAS" );
   
    Ini_PutInt (iniStation, section, "frameWidth", frameWidth);
    Ini_PutInt (iniStation, section, "frameHeight", frameHeight);

0 Kudos
Message 5 of 33
(4,571 Views)

nevermind I found what i was doing wrong. this is the code i have now

 

    GetProjectDir (dirName);
    MakePathname (dirName, "Config.ini", pathName);
    Ini_Dispose( iniStation );
    iniStation = Ini_New( 0 );
    Ini_PutInt (iniStation, "DAS", "frameWidth", frameWidth);
    Ini_PutInt (iniStation, "DAS", "frameHeight", frameHeight);
    Ini_WriteToFile (iniStation, pathName);
    system("notepad Config.ini");
 

0 Kudos
Message 6 of 33
(4,559 Views)

OK. And then?? Till now you are handling an object in memory. If you want to have a copy on disk you will need to write it somewere: use Ini_WriteToFile for this.

As a side note, it's better that you add error checking at least to Ini_Create and Ini_WriteToFile functions, which are the most critical as they deal with memory allocation and file I/O.

Do you get any error till now?



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?
Message 7 of 33
(4,558 Views)
i didnt get no error, but yeah i always add my error handling afterwards. give me example of what you are talking about.
0 Kudos
Message 8 of 33
(4,555 Views)
Don't bother, I see you were posting some new code while I was writing my message.


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?
Message 9 of 33
(4,554 Views)

   Hi Im using this logic, I having a problem, everytime I run the program, the program creates a new ini file, instead of just outting the values in without

   erasing the entire file. do you know why is that ?

   

    GetProjectDir(directoryPathName);
    MakePathname(directoryPathName,CONFIG_FILE2,iniFilePathName);
    Ini_Dispose(iniStationController);
    iniStationController=Ini_New( 0 );
    Ini_PutInt(iniStationController, "DAS", "X_BORESIGHT", offSetXposition);
    Ini_PutInt(iniStationController, "DAS", "Y_BORESIGHT", offSetYposition);
    Ini_WriteToFile(iniStationController, iniFilePathName);

0 Kudos
Message 10 of 33
(4,527 Views)