LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Fmt question

I don't understand what's happening in this line of code.  I cannot find "discharge_data" anywhere else in any of the files of this project.

 

Fmt (&file_string[0], "%s<%s\\discharge_data\\%sdis.txt", path, serial_number);

0 Kudos
Message 1 of 5
(825 Views)

This line of code is formatting a string that is composed of four parts: path, the constant \\discharge_data\\ , serial_number and ending with 'dis.txt'.

 

So the author of this code line obviously wanted to save data to a file xxxdis.txt in the subdirectory ...\discharge_data

 

More on the Fmt command can be found, e.g., here

0 Kudos
Message 2 of 5
(795 Views)

Thanks Wolfgang, your response provided enough of a clue that I discovered that the discharge_data folder did not exist.  But the linked information did not explain to ME how the formatted string gets spliced together.  It certainly did not help me decipher this.

 

Fmt (function_string, "%s<%s[w5]\042%s[w7]\042", "FUNC ", "VOLT:DC");

 

That is supposed to be a command to an HP6653A power supply.  I can't find FUNC anywhere in the power supply manual.  How would this command look?

0 Kudos
Message 3 of 5
(674 Views)

@Jim_Marihew wrote:

Thanks Wolfgang, your response provided enough of a clue that I discovered that the discharge_data folder did not exist.  But the linked information did not explain to ME how the formatted string gets spliced together.  It certainly did not help me decipher this.

 

Fmt (function_string, "%s<%s[w5]\042%s[w7]\042", "FUNC ", "VOLT:DC");


The Fmt() functions certainly have a fairly long explanation of the various formatting string options.

 

This basically takes the first 5 characters from the first parameter, add an ASCI character with octal value 42 (the double quote), then takes 7 characters from the second parameter and adds another octal value 42.

 

So the result is <FUNC "VOLT:DC">  (without the brackets)

Rolf Kalbermatter
My Blog
Message 4 of 5
(660 Views)

Well, that makes a little more sense.  I was thinking decimal 42 (*).  The VOLT:DC part makes sense, but neither FUNC nor FUNCTION appears anywhere in the commands list.  I hate inherited code!  Thanks Rolf.

0 Kudos
Message 5 of 5
(603 Views)