Jump to content

LabVIEW variables


c_w_k

Recommended Posts

Hello,

I'm wondering how I should go about creating variables in LabVIEW, I'm trying to do the following C++ code in LabVIEW. Its a very simple to do in C++ and I'm sure it is in LabVIEW, but I'm new to LabVIEW and haven't came across this situation yet.

myStruct status;

old_s0;

old_s1;

old_s0 = -1;

old_s1 = -1;

if( status.s0 != old_s0 || status.s1 != old_s1 )

{

old_s0 = status.s0; <-----------this is the part that i'm confused on, how can i make a variable that i can change the value of

old_s1 = status.s1; <-----------old_s0 and old_s1.

}

thanks for any and all ideas

-CK

Link to comment

Hello,

I'm wondering how I should go about creating variables in LabVIEW, I'm trying to do the following C++ code in LabVIEW. Its a very simple to do in C++ and I'm sure it is in LabVIEW, but I'm new to LabVIEW and haven't came across this situation yet.

There are no variables in LabVIEW, just values on wires. Given the very limited amount of C++ code you posted there's no way to say what a good direct equivalent would be in LabVIEW; you need to provide more context. What are you actually trying to do? Post the LabVIEW code you already have and explain what it is you need it to accomplish.

Link to comment

Ned,

I have no LabVIEW code yet for this.

I have a C++ struct, from that I get the s0 and s1 variables, I want to compare these variables with the old_s0 and old_s1 variables. I have set the variables of "old_s0" and "old_s1" to a value of "-1" because the first value from the s0 and s1 variables will be "0".

So for example, if s0 has a value of "0" and s0_old has a current value of "-1"......since these do not match, I want to set the value of s0_old to the value of s0, and the same for s1 and s1_old. The status struct is in a loop so the s0 and s1 variables will always keep adding by 1 but they start at zero....

Link to comment

CK,

This is an approximation to what you described. The "variables" are the wires and the Shift Registers carry them from one loop iteration to the next. See how I've created your struct as a clusters; I took the liberty to do the same with old_s0 and old_s1 just to make it easier to propagate them to the next iteration.

The other case in the Case Structure has the old wired straight through, and I've got a True constant wired to the loop condition just for this example.

post-7534-125805135531_thumb.png

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.