Some courses and learning paths on NI Learning Center may not appear on learner dashboards. Our team is actively investigating.

If you encounter access issues, please contact services@ni.com and include the learner’s name, email, service ID or EA number, and the list of required courses.

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
(1,712 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
(1,682 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
(1,561 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
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
Message 4 of 5
(1,547 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
(1,490 Views)