I did some test about parameter passing and I successfully passed / retrieved a single parameter, but what if I have to pass more than one?
Can I directly retrieve a command line parameter using something like params[0] or they are retrieved all in single bunch using "value" and I have to do the parsing of parameters to extract them once retrieved by "value"?
There is no special code for parameter passing, all parameters are passed in a single line, you can split it and isolate the different parameters.
I easily did it but I'm thinking to give up......
I was doing what I thought to be something simple, but I really didn't succeed to understand how variables work in a TC's device definitions then I am not able to write a working function using some parameters passing (in/out). I didn't understand their scope, how to declare them, to retrieve their value, and probably also how to assign a value to a variable.
What I was going to do is write something simple, a function to set or reset a bit passing it the bit position as parameter, in a 16 bit register which value is also passed as parameter (alternatevely passing the register address as parameter, but this is surely a bit more complex).
The function has simply to return the new register value which the calling function has to write to the desidered register.
I coded quickly a working function (#scpiCmd MyFunction #pgm#) passing it immediate values as parameters (like 256,3,1 - Set bit 3 to 1, 256 is the initial register value).
The trouble begun trying to pass parameters as LastRegValue,3,1.
Any temptative I did was unsuccessful, using parentesis does not solve.
Defining it using :setvar: LastRegValue=value in a #scpiCmd was ineffective. OK, I thought it has a local scope and I cannot reference it in a #cmdsetup# where I need to call my function, then I tryed to define LastRegValue as Globalvar in a #scpiCmd SetVars #pgm# command called in initCmd at the beginning. I can correctly retrieve its value from the command line and in my function, but I cannot set the global variable with the necessary value inside a #cmdsetup# calling a working #scpiCmd# that retrieves the register's value.
Similary for the function return value. I tried to use print(returnvalue) as described but I cannot retrieve its value anywhere. The use of a global variable seems to work (I am not absolutely sure, I did too much tentatives to be sure of it).
At this point I suppose variables in TC work in an unusual way and surely I did not understand it.