AnsweredAssumed Answered

User Input in programing VISA ?

Question asked by designer6 on Sep 5, 2008
Latest reply on Sep 8, 2008 by dgun
Hi,

I have a question Is this possible in programing VISA to allow the user manually enter the command code instead of hard code the command in the program.

for example.
This is a hard code in IDN command line

/*idn.c
  This example program queries a GPIB device for an identification string
  and prints the results. Note that you must change the address. */

  /* Send an *IDN? string to the device */
  viPrintf (vi, "*IDN?\n");
 
  /* Read results */
  viScanf (vi, "%t", &buf);

  /* Print results */
  printf ("Instrument identification string: %s\n", buf);

  /* Close session */
  viClose (vi);
  viClose (defaultRM);
}


Instead
Do something like this where i ask the user to enter in a command and pass it. But when i test the code it doesn't work.

char cmd [40];
printf ("What command do you wish to enter?\n")
scanf (cmd);
/* Send an *IDN? string to the device */
  viPrintf (vi, "cmd\n");
/* Read results */
  viScanf (vi, "%t", &buf);

  /* Print results */
  printf ("Instrument identification string: %s\n", buf);

  /* Close session */
  viClose (vi);
  viClose (defaultRM);


Regards,
Designer  

Outcomes