03-05-2017 01:57 PM
hiiii,I want some examples to create a generic function with switch case thx .
Solved! Go to Solution.
03-05-2017 05:00 PM
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.
03-19-2017 08:05 AM
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 😞
03-19-2017 06:49 PM - edited 03-19-2017 06:54 PM
Well, I suppose the difficult part is what to switch on. There can be multiple answers to this question:
switch (protocol) { case 1: // Telnet break; case 2: // RS232 break; }
#define TELNET 1 #define RS232 2and then switch on the defined values:
swich (protocol) { case TELNET: break; case RS232: break; }
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