410 ‘ —— CHECK MESSAGE AVAILABLE BIT ——
420 WHILE SPR% AND 16
430 PRINT “ Message available bit set”
440 MSG$ = SPACE$(255)
450 CALL IBRD (CNT%, MSG$)
460 LFPOS = INSTR(MSG$, CHR$(10))
470 IF LFPOS <> 0 THEN PRINT “Response = ” LEFT$(MSG$,
LFPOS)
480 IF LFPOS = 0 THEN PRINT “Response = ”; MSG$
490 CALL IBRSP (CNT%, SPR%)
500 WEND
510 ‘
520 ‘ —— CHECK EVENT STATUS BIT ——
530 IF NOT SPR% AND 32 GOTO 750
540 PRINT “ Event status bit set”
550 WRT$ = “*esr?”
560 CALL IBWRT (CNT%, WRT$)
570 ESR$ = SPACE$(255)
580 CALL IBRSP (CNT%, SPR%)
590 CALL IBRD (CNT%, ESR$)
600 ESR% = VAL(ESR$)
610 IF ESR% AND 32 THEN PRINT “ Command error”
620 IF ESR% AND 16 THEN PRINT “ Execution error”
630 IF ESR% AND 4 THEN PRINT “ Query error”
640 ‘
650 ‘ —— READ ERROR MESSAGES ——
660 WRT$ = “syst:err?”
670 ERRMESS$ = SPACE$(255)
680 CALL IBWRT (CNT%, WRT$)
690 CALL IBRD (CNT%, ERRMESS$)
700 WHILE NOT INSTR(ERRMESS$, “No error”) <> 0
710 PRINT LEFT$(ERRMESS$, INSTR(ERRMESS$, CHR$(10)))
720 CALL IBWRT (CNT%, WRT$)
730 CALL IBRD (CNT%, ERRMESS$)
740 WEND
750 WEND
760 PRINT “PROGRAM TERMINATED”
770 END
Programming Examples
4-10 GW-Basic for National Instruments PC-IIA, Setting Up the Interface