04-06-2018 09:16 AM
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
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.
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.
04-06-2018 10:46 AM
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.
04-06-2018 11:04 AM
Just glancing at one of the pictures for now:
@AldhairGarza wrote:
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!
04-06-2018 11:12 AM
@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.
04-06-2018 11:23 AM
@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?
04-06-2018 11:47 AM
(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".
04-06-2018 11:56 AM
@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.
04-06-2018 12:08 PM - edited 04-06-2018 12:10 PM
@altenbach wrote:
Just glancing at one of the pictures for now:
@AldhairGarza wrote:
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.
04-09-2018 05:40 AM
Thank you very much for your feedback.
As @billko said I didn't do a large Concatenate Strings for clarity. I did that with the free labels and now the display format is shown.
But you are right @altenbach Format into String is better to use. I changed the "Space Generator" and the "Code" is now I32, I don't know why it was DBL. Now i think it looks better.
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.
@crossrulz Sorry I don't really understand this function you mention, but you meant just replacing this block?
Could you guys give Feedback for the another VI ?
Best Regards.
04-09-2018 06:29 AM - edited 04-09-2018 06:30 AM
@AldhairGarza wrote:
@crossrulz Sorry I don't really understand this function you mention, but you meant just replacing this block?
Close. You need to wire up the "from" input and set it to end (it defaults to Start).