From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I need your Feedback for a VI

Hello everyone,

 

Resume: Please review the VI's (2 of them) and give me your feedback.

 

Explanation: The purpose of these VI's is to give Format to a Text. I'm working with Teststand and if an error happens it must be written into a File. I tried my best to make it readable and to documen it. Iwould higly appreciate any comment on this VI's. Thank you.

 

The File must be something like this

 Text Example.PNG

The VI's work very fine, but i'm curious of it's the correct way to do it or if my code is actually redundant and bad done. I'm curious too of how would be your own logic to do such a programm.

 

ErrorLogger.pngparagraph_format.png

 

This last VI just writes the text into a .txt file and then reads the text from it, just to clean the format and avoid problems.

FormatCleaning.png

=======
My Channel: https://www.youtube.com/@LV_Lab

0 Kudos
Message 1 of 23
(3,434 Views)

For your last VI, instead of reading the entire file just use the Set File Position.  There is an input for a reference point.  Set that to be End and a 0 to the count.  The file pointer is now at the end of the file and is a little more efficient than reading the entire thing.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 23
(3,400 Views)

Just glancing at one of the pictures for now:

 


@AldhairGarza wrote: 

ErrorLogger.png

 

 

 


 

All your complicated and scattered concatenate operations can be replaced by "format into string". Set the formatting statement for "\-codes to more easily see the special characters. For example the top box could have a statement with two inputs and the format in (\-codes) as "%s Steps:\s\s\s\s%s\n"

In fact you can expand on that and create a single long formatting statement combining all the various inputs into the final string directly. (e.g. "%s Steps:\s\s\s\s%s\n  .(etc. etc.) ... Code:\s\s\s\s%d/n/n/n). Even the time could be directly formatted from a timestamp.

 

Your space generator could use "initialize array" with the correct length and the right U8 character (decimal 32) followed by a typecast. No loop needed.

 

Why is "Code" DBL instead of I64? Change the representation of the control!

 

 

Message 3 of 23
(3,391 Views)

@altenbach wrote:

Your space generator could use "initialize array" with the correct length and the right U8 character (decimal 32) followed by a typecast. No loop needed.


I get a chance to correct Christian!  This is a rare moment!

 

Instead of Type Cast, use Byte Array To String.  It is literally a noop since an array of bytes and a string have the exact same data structure.

 

And for the Format Into String, the format string will handle \ codes without changing the display format of the string.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 23
(3,386 Views)

@crossrulz wrote:
Instead of Type Cast, use Byte Array To String.  It is literally a noop since an array of bytes and a string have the exact same data structure.

 


So you are saying typecast is not a NOOP here?

0 Kudos
Message 5 of 23
(3,384 Views)

(Still commenting on the top picture)

 

In fact, you can even combine the formatting and file writing into one single operation using "format into file".

0 Kudos
Message 6 of 23
(3,378 Views)

@altenbach wrote:

@crossrulz wrote:
Instead of Type Cast, use Byte Array To String.  It is literally a noop since an array of bytes and a string have the exact same data structure.

So you are saying typecast is not a NOOP here?


Honestly, I do not know.  I do know that the Type Cast rarely is a simple "redefine these bytes".  But I have been flat out told about the Byte Array To String and String To Byte Array being noops by those inside of R&D.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 23
(3,371 Views)

@altenbach wrote:

Just glancing at one of the pictures for now:

 


@AldhairGarza wrote: 

ErrorLogger.png

 

 

 


 

All your complicated and scattered concatenate operations can be replaced by "format into string". Set the formatting statement for "\-codes to more easily see the special characters. For example the top box could have a statement with two inputs and the format in (\-codes) as "%s Steps:\s\s\s\s%s\n"

In fact you can expand on that and create a single long formatting statement combining all the various inputs into the final string directly. (e.g. "%s Steps:\s\s\s\s%s\n  .(etc. etc.) ... Code:\s\s\s\s%d/n/n/n). Even the time could be directly formatted from a timestamp.

 

Your space generator could use "initialize array" with the correct length and the right U8 character (decimal 32) followed by a typecast. No loop needed.

 

Why is "Code" DBL instead of I64? Change the representation of the control!

 

 


Sometimes I will use multiple concatenate strings if, for instance, I am assembling a string of parameters, for clarity.  I will have labels pointing to each concatenate string showing exactly what part of the parameter is being constructed.  I believe this is what is happening here.  (They're "grouped" with decorations.  It would have been nicer if some free labels accompanied the them, though.

 

To the OP: You should always show the display style of a string, or the radix of a numeric, if it is anything other than the default so people will know how to interpret what they are seeing.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 8 of 23
(3,367 Views)

Thank you very much for your feedback.

As  @

But you are right @
errorlogggingsnippet.png

wrote:

For your last VI, instead of reading the entire file just use the Set File Position.  There is an input for a reference point.  Set that to be End and a 0 to the count.  The file pointer is now at the end of the file and is a little more efficient than reading the entire thing.


@ Sorry I don't really understand this function you mention, but you meant just replacing this block?

 

filereading.png

 

Could you guys give Feedback for the another VI ? 

 

Best Regards.

=======
My Channel: https://www.youtube.com/@LV_Lab

0 Kudos
Message 9 of 23
(3,314 Views)

@AldhairGarza wrote:

@ Sorry I don't really understand this function you mention, but you meant just replacing this block?

 

filereading.png


Close.  You need to wire up the "from" input and set it to end (it defaults to Start).


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 10 of 23
(3,302 Views)