LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

labwindows generic function

Solved!
Go to solution

hiiii,I want some examples to create a generic function with switch case thx . 

0 Kudos
Message 1 of 4
(2,731 Views)

Unfortunately "generic function with a switch" is too generic a concept for us to understand your needs.

The easiest example of a function with a switch is maybe a control callback, otherwise CVI comes plenty of examples that define functions with or without switches.

What are you really trying to do? We can give you a better help if you refine a bit more your question.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 2 of 4
(2,703 Views)

thank you very much sir ...
I need to make a generic application with its interface to test the protocols of a modem. The protcols are telnet, ssh, rs232, bat.
The function will be as follows "function test (protocol, command, start tag, end tag, measure (0 or 1), limit inf, limit sup, repose") at least I want a structure and how I do the coding , am blocked 😞

0 Kudos
Message 3 of 4
(2,611 Views)
Solution
Accepted by topic author khaoula555

Well, I suppose the difficult part is what to switch on. There can be multiple answers to this question:

 

  1. You can simply consider to use arbitrary values for specific protocols (e.g. 1=telnet, 2=rs232 and so on) without defining or declaring them elsewhere, and then switch on those values:
    switch (protocol) {
      case 1:     // Telnet
        break;
      case 2:     // RS232
        break;
    }
  2. You could #define constants for your protocols; e.g.
    #define TELNET  1
    #define RS232  2
    and then switch on the defined values:
    swich (protocol) {
      case TELNET:
        break;
      case RS232:
        break;
    }
  3. Similar to a series of #defines is the use of an enumerated type:
    enum PROTOCOL { UNDEFINED, TELNET, RS232 }
    The switch in this case is similar to case 2 above

I can think to other solutions as well, those above are only the more classical and maybe the simpler you can adopt.

 

This is more a basic question on C programming rather that a doubt on CVI: you should revise you programming basics with a good manual or some online resource like this on switch and enumerated types

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 4 of 4
(2,606 Views)