1000 ! RE-SAVE "VFP"
1001 !*************************************************
1002 !*
1003 !* FILE       :  VFP
1004 !* DESCRIPTION:  Agilent E5250A Viltual Front Panel Program
1005 !* AUTHOR     :  Tomohiko Matsui
1006 !* CREATED    :  10/27/1995
1007 !* MODIFIED   :  11/09/2000
1008 !* PRODUCT    :  Agilent E5250A
1009 !* REVISION   :  Rev.A.02.02
1010 !*
1011 !*   (c) Copyright 1995,2000 Agilent Technologies Co,
1012 !*              All rights reserved.
1013 !*
1014 !*************************************************
1015  OPTION BASE 1
1016  COM /Err/ Err_num(1:6),Err_message$(1:6)[80]
1017  COM /Ctrldev/ Sys_os$[20],@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1018  COM /Card_type/ No_card$[10],Card_type$(1:5)[10],Sys_id$[10],INTEGER Max_card_type
1019  COM /Card/ Card_desc$(0:4)[50],Card_conf$(0:4)[6],Card_info$(0:4)[6]
1020  COM /Label/ Input_label$(1:10)[5],Bias_label$(1:4,1:3)[5]
1021  COM /Setup/ INTEGER Config_mode,Bias_stat(0:4),Bias_port(0:4)
1022  COM /Setup_tmp/ INTEGER Conf_mode_tmp,Bias_stat_tmp(0:4),Bias_port_tmp(0:4)
1023  COM /Setup_mem/ Setup_mem$(1:24,1:4,1:10)[12],Setup_comm$(1:24)[20],INTEGER Curr_setup_num
1024  COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(1:12,1:2)
1025  COM /Set_panel/ Curr_card_num,Cursor_pos(1:2,1:1),Xy_pos(1:2,1:1),Curr_page,Max_col,Max_row,Xy_offset(1:2,1:1),Max_disp_col
1026  COM /Set_panel2/ Max_out,Max_in,Block_list(1:6,1:12,1:2)
1027  COM /File/ File_dev$[30]
1028  COM /Ctrldata/ Chan_list$[1800]
1029  COM /Init/ Def_port_num,Init_config$[5]
1030  COM /Revision/ Rev_id$[7]
1031  !==========================================================
1032  CLEAR SCREEN
1033  GINIT
1034  GCLEAR
1035  GOSUB Array_init
1036  SELECT SYSTEM$("SYSTEM ID")
1037  CASE "HP 4155A"
1038    Sys_os$="IBASIC"
1039  CASE "HP 4156A"
1040    Sys_os$="IBASIC"
1041  CASE "HP 4155B"
1042    Sys_os$="IBASIC_N"
1043  CASE "HP 4156B"
1044    Sys_os$="IBASIC_N"
1045  CASE "HP 4155C"
1046    Sys_os$="IBASIC_N"
1047  CASE "HP 4156C"
1048    Sys_os$="IBASIC_N"
1049  CASE ELSE
1050    Sys_os$="HP-BASIC"
1051  END SELECT
1052  Rev_id$="A.01.00"
1053  Sys_id$="E5250"
1054 Card_type_set:DATA "E5252","E5255","","",""
1055  RESTORE Card_type_set
1056  READ Card_type$(*)
1057  Max_card_type=2
1058  No_card$="-----"
1059  Def_port_num=10
1060  Init_config$="NCON"
1061 Def_frame_label:DATA "IV1","IV2","IV3","IV4","IV5"
1062  DATA "IV6","HF1","HF2","CV1","CV2"
1063  RESTORE Def_frame_label
1064  READ Input_label$(*)
1065 Def_bias_label:DATA "C1B1","C1B2","C1B3"
1066  DATA "C2B1","C2B2","C2B3"
1067  DATA "C3B1","C3B2","C3B3"
1068  DATA "C4B1","C4B2","C4B3"
1069  RESTORE Def_bias_label
1070  READ Bias_label$(*)
1071  X_org=2
1072  Y_org=1
1073  X_gorg=2
1074  Y_gorg=395
1075  X_step=8
1076  Y_step=14
1077  H_c=10
1078  W_c=5
1079  Curr_page=1
1080  Max_disp_col=48
1081  SELECT Sys_os$
1082  CASE "IBASIC"
1083    File_dev$=":INTERNAL,4"
1084  CASE "IBASIC_N"
1085    File_dev$=":INTERNAL,4"
1086    X_gorg=3
1087    Y_gorg=472
1088    X_step=9
1089    Y_step=17
1090    H_c=12
1091    W_c=8
1092  CASE ELSE
1093    File_dev$=""
1094  END SELECT
1095  Hpib_sc=7
1096  Hpib_addr=22
1097  Addr_5250=Hpib_sc*100+Hpib_addr
1098  !==========================================================
1099  GOSUB Softkey_clear
1100  CALL Set_5250_addr
1101  PRINT "E5250A GPIB Address = ";Addr_5250
1102  ON ERROR GOTO Assign_error
1103  ASSIGN @Hp5250 TO Addr_5250
1104  OFF ERROR 
1105  CALL Init_5250
1106  IF FNErr_check<>0 THEN Error_disp
1107  GOSUB Set_main_fkey
1108  CALL Main_menu
1109  LOOP
1110  END LOOP
1111  GOTO Prog_end
1112  !----------------------------------------------------------
1113 Set_main_fkey:GOSUB Softkey_clear
1114  ON KEY 1 LABEL " SHOW   CONFIG" CALL Show_config
1115  ON KEY 2 LABEL " SETUP  MODE  " CALL Setup_mode
1116  ON KEY 3 LABEL " DEFINE LABEL " CALL Define_label
1117  ON KEY 4 LABEL " SETUP  MEMORY" CALL Setup_memory
1118  ON KEY 5 LABEL " SAVE/  LOAD  " CALL Save_load_data
1119  ON KEY 7 LABEL " QUIT         " GOTO Prog_end
1120  RETURN 
1121 Softkey_clear:!
1122  FOR Key_no=1 TO 8
1123    ON KEY Key_no LABEL "" GOSUB Key_null
1124  NEXT Key_no
1125  RETURN 
1126 Key_null:RETURN 
1127 Array_init:MAT Err_num= (0)
1128  MAT Err_message$= ("ERROR")
1129  MAT Card_desc$= ("")
1130  MAT Card_conf$= ("")
1131  MAT Card_info$= ("")
1132  MAT Input_label$= ("")
1133  MAT Bias_label$= ("")
1134  MAT Bias_stat= (-1)
1135  MAT Bias_port= (-1)
1136  MAT Setup_mem$= (" ")
1137  MAT Setup_comm$= ("")
1138  RETURN 
1139 Assign_error:BEEP 
1140  DISP "*** "&ERRM$
1141  GOTO Prog_end2
1142 Error_disp:CALL Err_disp
1143  GOTO Prog_end2
1144 Prog_end:CLEAR SCREEN
1145  DISP "Virtual Front Panel Utility End !!"
1146 Prog_end2:Err=FNReset_5250
1147  ASSIGN @Hp5250 TO *
1148  BEEP 
1149  END
1150  !==========================================================
1151 Error_set:SUB Error_set(INTEGER Row_num,Err_no,Err_str$)
1152  !----- Error Data Setting ---------------------------------
1153    COM /Err/ Err_num(*),Err_message$(*)
1154    Err_num(Row_num)=Err_no
1155    Err_message$(Row_num)=Err_str$
1156  SUBEND
1157  !==========================================================
1158 Err_check:DEF FNErr_check
1159  !----- Error Data Check -----------------------------------
1160    COM /Err/ Err_num(*),Err_message$(*)
1161    Max_err_num=SIZE(Err_num,1)
1162    Err_stat=0
1163    FOR I=1 TO Max_err_num
1164      IF (Err_num(I)<>0) THEN 
1165        Err_stat=Err_stat+1
1166      END IF
1167    NEXT I
1168    RETURN Err_stat
1169  FNEND
1170  !==========================================================
1171 Err_disp:SUB Err_disp
1172  !----- Error Data Display ---------------------------------
1173    COM /Err/ Err_num(*),Err_message$(*)
1174    Max_err_num=SIZE(Err_num,1)
1175    N_err=0
1176    FOR I=1 TO Max_err_num
1177      IF (Err_num(I)<>0) THEN 
1178        N_err=N_err+1
1179      END IF
1180    NEXT I
1181    IF N_err>0 THEN 
1182      I=1
1183      LOOP
1184        IF Err_num(I)<>0 THEN 
1185          N_err=N_err-1
1186        END IF
1187      EXIT IF N_err=0
1188        I=I+1
1189        BEEP 
1190        DISP Err_message$(I)&" [Press Continue]"
1191        PAUSE
1192      END LOOP
1193      IF Err_num(I)<>0 THEN 
1194        BEEP 
1195        DISP Err_message$(I)
1196      END IF
1197    END IF
1198  SUBEND
1199  !==========================================================
1200 Main_menu:SUB Main_menu
1201  !----- Main Menu Display ----------------------------------
1202    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
1203    Xp=X_org
1204    Yp=Y_org
1205    CLEAR SCREEN
1206    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
1207    PRINT TABXY(Xp,Yp+2);"** MAIN MENU **"
1208    PRINT TABXY(Xp+2,Yp+4);"SHOW CONFIG   ...  Show installed card configuration"
1209    PRINT TABXY(Xp+2,Yp+5);"SETUP MODE    ...  Setup E5250A control mode       "
1210    PRINT TABXY(Xp+2,Yp+6);"DEFINE LABEL  ...  Define input port label name     "
1211    PRINT TABXY(Xp+2,Yp+7);"SETUP MEMORY  ...  Setup & control Setup Memory     "
1212    PRINT TABXY(Xp+2,Yp+8);"SAVE/LOAD     ...  Save/Load data file              "
1213    PRINT TABXY(Xp+2,Yp+11);"Set up E5250A control mode by pressing [SETUP MODE]"
1214    PRINT TABXY(Xp+2,Yp+12);"softkey befor setting the setup memory.            "
1215    PRINT TABXY(Xp+2,Yp+13);"Because if control mode is changed, all setup memory"
1216    PRINT TABXY(Xp+2,Yp+14);"will be cleard.                                    "
1217    DISP "Select desired softkey."
1218  SUBEND
1219  !==========================================================
1220 Set_5250_addr:SUB Set_5250_addr
1221  !----- E5250A Address Setting --------------------------
1222    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1223    Min_hpib_sc=7
1224    Max_hpib_sc=14
1225    Min_hpib_addr=0
1226    Max_hpib_addr=30
1227 Input_address:ON ERROR GOTO Hpib_addr_err
1228    DISP "Input E5250A GPIB Address. (default "&VAL$(Addr_5250)&") : ";
1229    INPUT " ",Tmp_addr_str$
1230    IF Tmp_addr_str$<>"" THEN 
1231      Tmp_addr=VAL(Tmp_addr_str$)
1232    ELSE
1233      Tmp_addr=Addr_5250
1234    END IF
1235    OFF ERROR 
1236    GOSUB Hpib_addr_check
1237    DISP "Input E5250A GPIB Address. (default "&VAL$(Addr_5250)&") : "&VAL$(Tmp_addr)
1238    CLEAR SCREEN
1239    Addr_5250=Tmp_addr
1240    SUBEXIT
1241 Hpib_addr_check:!
1242    IF FRACT(Tmp_addr)>0 THEN 
1243      DISP "E5250A GPIB Address is wrong"
1244      GOTO Hpib_addr_err
1245    END IF
1246    Tmp_hpib_sc=INT(Tmp_addr/100)
1247    Tmp_hpib_addr=Tmp_addr-Tmp_hpib_sc*100
1248    IF Tmp_hpib_sc<Min_hpib_sc OR Tmp_hpib_sc>Max_hpib_sc THEN 
1249      DISP "GPIB Select Code is wrong"
1250      GOTO Hpib_addr_err
1251    END IF
1252    IF Tmp_hpib_addr<Min_hpib_addr OR Tmp_hpib_addr>Max_hpib_addr THEN 
1253      DISP "GPIB Address is wrong"
1254      GOTO Hpib_addr_err
1255    END IF
1256    Hpib_addr=Tmp_hpib_addr
1257    RETURN 
1258 Hpib_addr_err:BEEP 
1259    Tmp_addr_str$=""
1260    GOTO Input_address
1261  SUBEND
1262  !==========================================================
1263 Init_5250:SUB Init_5250
1264  !----- E5250A Check & Initiarize -----------------------
1265    IF FNReset_5250<>0 THEN Error_end
1266    IF FNCheck_5250id<>0 THEN Error_end
1267    IF FNCard_info<>0 THEN Error_end
1268    CALL Card_init_set
1269    IF FNErr_check<>0 THEN Error_end
1270    SUBEXIT
1271 Error_end:CALL Err_disp
1272  SUBEND
1273  !==========================================================
1274 Reset_5250:DEF FNReset_5250
1275  !----- E5250A Reset ------------------------------------
1276    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1277    INTEGER Ctime
1278    Ctime=5
1279    ON TIMEOUT Hpib_sc,Ctime GOTO Time_out
1280    ON ERROR GOTO Io_error
1281    CLEAR @Hp5250
1282    LOCAL Hpib_sc
1283    OUTPUT @Hp5250;"*RST"
1284    OUTPUT @Hp5250;"*CLS"
1285    OFF ERROR 
1286    GOTO End_sub
1287 Io_error:CALL Error_set(1,1,"*** "&ERRM$)
1288    GOTO End_sub
1289 Time_out:CALL Error_set(1,2,"GPIB address,connection or firmware is bad.")
1290 End_sub:OFF TIMEOUT 
1291    RETURN FNErr_check
1292  FNEND
1293  !==========================================================
1294 Check_5250id:DEF FNCheck_5250id
1295  !----- E5250 ID Check ------------------------------------
1296    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1297    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1298    INTEGER Ctime
1299    DIM Idstr$[50]
1300    Ctime=3
1301    ON TIMEOUT Hpib_sc,Ctime GOTO Time_out
1302    OUTPUT @Hp5250;"*IDN?"
1303    ENTER @Hp5250;Idstr$
1304    IF POS(Idstr$,Sys_id$) THEN 
1305      PRINT Idstr$
1306    ELSE
1307      CALL Error_set(1,3,"Instrument at address "&VAL$(Addr_5250)&" is not E5250A !")
1308    END IF
1309    GOTO End_sub
1310 Time_out:CALL Error_set(1,2,"GPIB address,connection or firmware is bad.")
1311 End_sub:OFF TIMEOUT 
1312    RETURN FNErr_check
1313  FNEND
1314  !==========================================================
1315 Card_info:DEF FNCard_info
1316  !----- E5250A CARD Information Read --------------------
1317    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1318    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1319    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1320    INTEGER Ctime
1321    DIM C_tmp$[50],Corp_id$[30],C_model$[10],C_sn$[10],C_rev$[10]
1322    Ctime=3
1323    Max_slot_no=(SIZE(Card_info$,1)-1)
1324    ON TIMEOUT Hpib_sc,Ctime GOTO Time_out
1325    FOR Slot_no=1 TO Max_slot_no
1326      OUTPUT @Hp5250;":SYST:CDES? "&VAL$(Slot_no)
1327      ENTER @Hp5250;Card_desc$(Slot_no)
1328      Card_desc$(Slot_no)=Card_desc$(Slot_no)[POS(Card_desc$(Slot_no),"""")+1,LEN(Card_desc$(Slot_no))]
1329      Card_desc$(Slot_no)=Card_desc$(Slot_no)[1,POS(Card_desc$(Slot_no),"""")-1]
1330      OUTPUT @Hp5250;":SYST:CTYP? "&VAL$(Slot_no)
1331      ENTER @Hp5250;C_tmp$
1332      Corp_id$=C_tmp$[1;(POS(C_tmp$,",")-1)]
1333      C_tmp$=C_tmp$[(POS(C_tmp$,",")+1);(LEN(C_tmp$)-POS(C_tmp$,","))]
1334      C_model$=C_tmp$[1;(POS(C_tmp$,",")-1)]
1335      C_tmp$=C_tmp$[(POS(C_tmp$,",")+1);(LEN(C_tmp$)-POS(C_tmp$,","))]
1336      C_sn$=C_tmp$[1;(POS(C_tmp$,",")-1)]
1337      C_rev$=C_tmp$[(POS(C_tmp$,",")+1);(LEN(C_tmp$)-POS(C_tmp$,","))]
1338      I=1
1339      LOOP
1340        Exit_fg=0
1341      EXIT IF I>Max_card_type
1342        IF POS(C_model$,Card_type$(I)) THEN 
1343          Exit_fg=1
1344        END IF
1345      EXIT IF Exit_fg=1
1346        I=I+1
1347      END LOOP
1348      IF Exit_fg=1 THEN 
1349        Card_info$(Slot_no)=Card_type$(I)
1350      ELSE
1351        Card_info$(Slot_no)=No_card$
1352      END IF
1353      IF Card_info$(Slot_no)=Card_type$(2) THEN 
1354        OUTPUT @Hp5250;":SYST:CCON? "&VAL$(Slot_no)
1355        ENTER @Hp5250;C_tmp$
1356        Tmp_str$=""
1357        Blen=FNBlock_data_conv(C_tmp$)
1358        FOR I=1 TO Blen
1359          Tmp_str$=Tmp_str$&(VAL$(NUM(C_tmp$[I;1])))
1360        NEXT I
1361        Card_conf$(Slot_no)=Tmp_str$
1362      ELSE
1363        Card_conf$(Slot_no)=""
1364      END IF
1365      IF Slot_no=1 THEN 
1366        Card_info$(0)=Card_info$(Slot_no)
1367        Card_desc$(0)=Card_desc$(Slot_no)
1368        Card_conf$(0)=Card_conf$(Slot_no)
1369      END IF
1370    NEXT Slot_no
1371    GOTO End_sub
1372 Time_out:CALL Error_set(1,2,"GPIB address,connection or firmware is bad.")
1373 End_sub:OFF TIMEOUT 
1374    RETURN FNErr_check
1375  FNEND
1376  !==========================================================
1377 Card_init_set:SUB Card_init_set
1378  !----- E5250A CARD Initiarize --------------------------
1379    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1380    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1381    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1382    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1383    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
1384    COM /Init/ Def_port_num,Init_config$
1385    Card_id$=Card_type$(1)
1386    Ctime=10
1387    Max_card_no=(SIZE(Card_info$,1)-1)
1388    ON TIMEOUT Hpib_sc,Ctime GOTO Time_out
1389    OUTPUT @Hp5250;":ROUT:FUNC NCON"
1390    Config_mode=0
1391    OUTPUT @Hp5250;":ROUT:BIAS:STAT ALL,OFF"
1392    FOR Card_no=0 TO Max_card_no
1393      Bias_stat(Card_no)=0
1394      IF Card_info$(Card_no)=Card_id$ THEN 
1395        IF Card_no>0 THEN 
1396          OUTPUT @Hp5250;":ROUT:BIAS:PORT "&VAL$(Card_no)&","&VAL$(Def_port_num)
1397        END IF
1398        Bias_port(Card_no)=Def_port_num
1399      ELSE
1400        Bias_port(Card_no)=-1
1401      END IF
1402    NEXT Card_no
1403    OFF TIMEOUT 
1404    IF FNAll_open_set<>0 THEN Set_error
1405    Curr_setup_num=1
1406    CALL All_setup_clear
1407    IF FNInit_check<>0 THEN Set_error
1408    SUBEXIT
1409 Time_out:OFF TIMEOUT 
1410    CALL Error_set(1,2,"GPIB address,connection or firmware is bad.")
1411    SUBEXIT
1412 Set_error:CALL Error_set(1,10,"Card Initialization Failed")
1413  SUBEND
1414  !==========================================================
1415 All_setup_clear:SUB All_setup_clear
1416  !----- All Setup memory clear -----------------------------
1417    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1418    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1419    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1420    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
1421    Max_slot=(SIZE(Card_info$,1)-1)
1422    Max_setup_mem=SIZE(Setup_mem$,1)
1423    Bias_dis$="-"
1424    MAT Setup_comm$= ("Open All")
1425    MAT Setup_mem$= (" ")
1426    FOR Card_no=1 TO Max_slot
1427      C_type$=FNCard_data_query$(Card_no,Max_input,Max_output)
1428      FOR Sp_num=1 TO Max_setup_mem
1429        FOR Inp_num=1 TO Max_input
1430          IF Setup_mem$(Sp_num,Card_no,Inp_num)<>Bias_dis$ THEN 
1431            Setup_mem$(Sp_num,Card_no,Inp_num)=RPT$(".",Max_output)
1432          END IF
1433        NEXT Inp_num
1434      NEXT Sp_num
1435    NEXT Card_no
1436  SUBEND
1437  !==========================================================
1438 Setup_clr_card:SUB Setup_clr_card(INTEGER Setup_num,REAL Card_no,Set_mem$(*))
1439  !----- Setup memory clear card ----------------------------
1440    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1441    Max_output_len=12
1442    Bias_dis$="-"
1443    C_type$=FNCard_data_query$(Card_no,Max_input,Max_output)
1444    IF C_type$="" THEN 
1445      Max_input=SIZE(Set_mem$,3)
1446      Max_output=12
1447      Setd$=" "
1448    ELSE
1449      Setd$="."
1450    END IF
1451    IF Card_no=0 THEN 
1452      FOR C_num=1 TO (SIZE(Card_info$,1)-1)
1453        IF Card_info$(C_num)=C_type$ THEN 
1454          FOR Inp_num=1 TO Max_input
1455            IF Set_mem$(Setup_num,C_num,Inp_num)<>Bias_dis$ THEN 
1456              Set_mem$(Setup_num,C_num,Inp_num)=RPT$(Setd$,Max_output)
1457            END IF
1458          NEXT Inp_num
1459        ELSE
1460          FOR Inp_num=1 TO (SIZE(Set_mem$,3))
1461            Set_mem$(Setup_num,C_num,Inp_num)=RPT$(" ",Max_output_len)
1462          NEXT Inp_num
1463        END IF
1464      NEXT C_num
1465    ELSE
1466      FOR Inp_num=1 TO Max_input
1467        IF Set_mem$(Setup_num,Card_no,Inp_num)<>Bias_dis$ THEN 
1468          Set_mem$(Setup_num,Card_no,Inp_num)=RPT$(Setd$,Max_output)
1469        END IF
1470      NEXT Inp_num
1471    END IF
1472  SUBEND
1473  !==========================================================
1474 All_open_set:DEF FNAll_open_set
1475  !----- All Card Open --------------------------------------
1476    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1477    INTEGER Err_n
1478    DIM Err_str$[80]
1479    OUTPUT @Hp5250;":ROUT:OPEN:CARD ALL"
1480    OUTPUT @Hp5250;"*OPC?"
1481    ENTER @Hp5250;Cp
1482    OUTPUT @Hp5250;":SYST:ERR?"
1483    ENTER @Hp5250;Err_n,Err_str$
1484    RETURN Err_n
1485  FNEND
1486  !==========================================================
1487 Conf_mode_check:DEF FNConf_mode_check$   !<1
1488  !----- Configuration Mode Check ---------------------------
1489    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1490    OUTPUT @Hp5250;":ROUT:FUNC?"
1491    ENTER @Hp5250;Conf_mode$
1492    RETURN Conf_mode$
1493  FNEND
1494  !==========================================================
1495 Bias_state_read:DEF FNBias_stat_read(Card_num) !<1
1496  !----- Bisa State Setting Check ---------------------------
1497    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1498    OUTPUT @Hp5250;":ROUT:BIAS:STAT? "&VAL$(Card_num)
1499    ENTER @Hp5250;Bstat
1500    RETURN Bstat
1501  FNEND
1502  !==========================================================
1503 Close_check:DEF FNClose_check(Card_num) !<1
1504  !----- Card switch closed check ---------------------------
1505    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1506    COM /Ctrldata/ Chan_list$
1507    DIM Tmp_chan_list$[1800]
1508    Sep$=","
1509    OUTPUT @Hp5250;":ROUT:CLOS:CARD? "&VAL$(Card_num)
1510    ENTER @Hp5250;Chan_list$
1511    IF LEN(Chan_list$)>0 THEN 
1512      Tmp_chan_list$=Chan_list$[2;(LEN(Chan_list$))-1]&Sep$
1513      Close_cnt=1
1514      LOOP
1515        Spos=POS(Tmp_chan_list$,Sep$)
1516      EXIT IF Spos=0
1517        Tmp_chan_list$=Tmp_chan_list$[Spos+1;(LEN(Tmp_chan_list$))-Spos]
1518        IF LEN(Tmp_chan_list$)>0 THEN 
1519          Close_cnt=Close_cnt+1
1520        END IF
1521      END LOOP
1522    ELSE
1523      Close_cnt=0
1524    END IF
1525    RETURN Close_cnt
1526  FNEND
1527  !==========================================================
1528 All_close_check:DEF FNAll_close_check
1529  !----- All Switch Open check ------------------------------
1530    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1531    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1532    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1533    Max_card_no=(SIZE(Card_info$,1)-1)
1534    Close_num=0
1535    IF Config_mode=0 THEN 
1536      Card_no=1
1537      LOOP
1538        SELECT Card_info$(Card_no)
1539        CASE Card_type$(1),Card_type$(2)
1540          Close_num=FNClose_check(Card_no)
1541        CASE ELSE
1542        END SELECT
1543      EXIT IF Close_num>0
1544        Card_no=Card_no+1
1545      EXIT IF Card_no>Max_card_no
1546      END LOOP
1547    ELSE
1548      Card_no=0
1549      Close_num=FNClose_check(Card_no)
1550    END IF
1551    RETURN Close_num
1552  FNEND
1553  !==========================================================
1554 Init_check:DEF FNInit_check
1555  !----- Initiarize setting check ---------------------------
1556    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1557    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1558    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1559    COM /Init/ Def_port_num,Init_config$
1560    Max_card_no=(SIZE(Card_info$,1)-1)
1561    IF FNConf_mode_check$<>Init_config$ THEN Init_error
1562    FOR Card_no=1 TO Max_card_no
1563      SELECT Card_info$(Card_no)
1564      CASE Card_type$(1)
1565        IF FNBias_stat_read(Card_no)<>0 THEN Init_error
1566        IF FNBias_port_read(Card_no)<>Def_port_num THEN Init_error
1567      CASE Card_type$(2)
1568        IF FNBias_stat_read(Card_no)<>0 THEN Init_error
1569      END SELECT
1570    NEXT Card_no
1571    IF FNAll_close_check>0 THEN Init_error
1572    RETURN 0
1573 Init_error:RETURN 1
1574  FNEND
1575  !==========================================================
1576 Bias_port_read:DEF FNBias_port_read(Card_num)  !<1
1577  !----- Bisa Port Setting Check ----------------------------
1578    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1579    OUTPUT @Hp5250;":ROUT:BIAS:PORT? "&VAL$(Card_num)
1580    ENTER @Hp5250;Bport
1581    RETURN Bport
1582  FNEND
1583  !==========================================================
1584 Block_data_conv:DEF FNBlock_data_conv(B_data$)
1585  !----- Block Format data convert --------------------------
1586    IF B_data$[1;1]="#" THEN 
1587      Clen=VAL(B_data$[2;1])
1588      IF Clen>0 THEN 
1589        Blen=VAL(B_data$[3;Clen])
1590        B_data$=B_data$[2+Clen+1;(LEN(B_data$)-(2+Clen))]
1591      ELSE
1592        Blen=0
1593      END IF
1594    ELSE
1595      Blen=0
1596    END IF
1597    RETURN Blen
1598  FNEND
1599  !==========================================================
1600 Show_config:SUB Show_config
1601  !----- Show Config Mode Main Routin -----------------------
1602    GOSUB Set_fkey
1603    CALL Show_conf_menu
1604    LOOP
1605    END LOOP
1606    GOTO Show_conf_end
1607 Set_fkey:!
1608    FOR Key_no=1 TO 8
1609      ON KEY Key_no LABEL "",2 GOSUB Key_null
1610    NEXT Key_no
1611    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Show_conf_end
1612    RETURN 
1613 Key_null:RETURN 
1614 Show_conf_end:CLEAR SCREEN
1615    CALL Main_menu
1616  SUBEND
1617  !==========================================================
1618 Show_conf_menu:SUB Show_conf_menu
1619  !----- Show configuration menu set ------------------------
1620    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1621    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1622    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1623    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
1624    DIM Card_desc_str$[50]
1625    DIM Card_conf_str$[50]
1626    DIM Info_str$[50]
1627    Xp=X_org
1628    Yp=Y_org
1629    Xof=2
1630    Yof1=2
1631    Row_offset=Yp+4
1632    Max_card_no=(SIZE(Card_info$,1)-1)
1633    Bias_num=3
1634    CLEAR SCREEN
1635    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
1636    PRINT TABXY(Xp,Yp+Yof1);"** SHOW CONFIGURATION MENU **"
1637    PRINT 
1638    FOR Card_no=1 TO Max_card_no
1639      Rows=(Card_no-1)*Bias_num+Card_no+Row_offset
1640      Card_desc_str$=Card_desc$(Card_no)
1641      Card_conf_str$=Card_conf$(Card_no)
1642      PRINT TABXY(Xp+Xof,Rows);"CARD"&VAL$(Card_no)&"    ...  "&Card_desc_str$
1643      SELECT Card_info$(Card_no)
1644      CASE Card_type$(2)
1645        FOR I=1 TO Bias_num
1646          Pt=(I-1)*2+1
1647          Inp_no$=Card_conf_str$[Pt;1]
1648          IF Card_conf_str$[(Pt+1);1]="0" THEN 
1649            Info_str$="Block "&VAL$(I)&" : Input "&Inp_no$&", "&"No Resistanse"
1650          ELSE
1651            Info_str$="Block "&VAL$(I)&" : Input "&Inp_no$&", "&"With Resistanse"
1652          END IF
1653          PRINT TABXY(Xp+Xof,Rows+I);"                 "&Info_str$
1654        NEXT I
1655      CASE ELSE
1656        FOR I=1 TO Bias_num
1657          PRINT TABXY(Xp+Xof,Rows+I);" "
1658        NEXT I
1659      END SELECT
1660    NEXT Card_no
1661    DISP "Select desired softkey."
1662  SUBEND
1663  !==========================================================
1664 Setup_mode:SUB Setup_mode
1665  !----- Setup Mode Main Routin -----------------------------
1666    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1667    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1668    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1669    COM /Setup_tmp/ INTEGER Conf_mode_tmp,Bias_stat_tmp(*),Bias_port_tmp(*)
1670    Max_card_no=(SIZE(Card_info$,1)-1)
1671    Conf_mode_tmp=Config_mode
1672    FOR I=0 TO Max_card_no
1673      Bias_stat_tmp(I)=Bias_stat(I)
1674      Bias_port_tmp(I)=Bias_port(I)
1675    NEXT I
1676    CALL Setup_mode_menu
1677    Key_redraw=1
1678    LOOP
1679      IF Key_redraw=1 THEN 
1680        IF Config_mode=0 THEN 
1681          GOSUB Set_nrml_fkey
1682        ELSE
1683          GOSUB Set_auto_fkey
1684        END IF
1685      END IF
1686    END LOOP
1687    GOTO Setup_mode_end
1688 Set_nrml_fkey:GOSUB Softkey_clear
1689    Key_redraw=0
1690    ON KEY 1 LABEL "CHANGE  CONFIG",2 GOSUB Conf_mode_chg
1691    IF Card_info$(1)<>No_card$ THEN 
1692      ON KEY 3 LABEL " CARD1        ",2 GOSUB Bias_data_set1
1693    END IF
1694    IF Card_info$(2)<>No_card$ THEN 
1695      ON KEY 4 LABEL " CARD2        ",2 GOSUB Bias_data_set2
1696    END IF
1697    IF Card_info$(3)<>No_card$ THEN 
1698      ON KEY 5 LABEL " CARD3        ",2 GOSUB Bias_data_set3
1699    END IF
1700    IF Card_info$(4)<>No_card$ THEN 
1701      ON KEY 6 LABEL " CARD4        ",2 GOSUB Bias_data_set4
1702    END IF
1703    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Setup_mode_end
1704    RETURN 
1705 Set_auto_fkey:GOSUB Softkey_clear
1706    Key_redraw=0
1707    ON KEY 1 LABEL " CHANGE CONFIG",2 GOSUB Conf_mode_chg
1708    ON KEY 3 LABEL " BIAS   STATE ",2 GOSUB B_stat_set_call
1709    SELECT Card_info$(Card_no)
1710    CASE Card_type$(1)
1711      ON KEY 4 LABEL " BIAS   PORT  ",2 GOSUB B_port_set_call
1712    CASE ELSE
1713    END SELECT
1714    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Setup_mode_end
1715    RETURN 
1716 Softkey_clear:!
1717    Key_redraw=1
1718    FOR Key_no=1 TO 8
1719      ON KEY Key_no LABEL "",2 GOSUB Key_null
1720    NEXT Key_no
1721    RETURN 
1722 Key_null:RETURN 
1723 Conf_mode_chg:GOSUB Softkey_clear
1724    CALL Conf_mode_set
1725    CALL Setup_mode_menu
1726    RETURN 
1727 Bias_data_set0:GOSUB Softkey_clear
1728    CALL Bias_data_set(0)
1729    RETURN 
1730 Bias_data_set1:GOSUB Softkey_clear
1731    CALL Bias_data_set(1)
1732    RETURN 
1733 Bias_data_set2:GOSUB Softkey_clear
1734    CALL Bias_data_set(2)
1735    RETURN 
1736 Bias_data_set3:GOSUB Softkey_clear
1737    CALL Bias_data_set(3)
1738    RETURN 
1739 Bias_data_set4:GOSUB Softkey_clear
1740    CALL Bias_data_set(4)
1741    RETURN 
1742 B_stat_set_call:GOSUB Softkey_clear
1743    CALL Bias_stat_set(Card_no)
1744    CALL Setup_mode_menu
1745    RETURN 
1746 B_port_set_call:GOSUB Softkey_clear
1747    CALL Bias_port_set(Card_no)
1748    CALL Setup_mode_menu
1749    RETURN 
1750 Setup_mode_end:CALL Setup_chg_check
1751    CLEAR SCREEN
1752    CALL Main_menu
1753  SUBEND
1754  !==========================================================
1755 Setup_mode_menu:SUB Setup_mode_menu
1756  !----- Setup Mode Menu Display ----------------------------
1757    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1758    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1759    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1760    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
1761    DIM Dstr$[100]
1762    Xp=X_org
1763    Yp=Y_org
1764    Xof=2
1765    Yof1=2
1766    Yof2=5
1767    Yof3=7
1768    Yof4=16
1769    Row_offset=Yp+8
1770    Max_card_no=(SIZE(Card_info$,1)-1)
1771    CLEAR SCREEN
1772    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
1773    PRINT TABXY(Xp,Yp+Yof1);"** SETUP MODE MENU **"
1774    PRINT 
1775    IF Config_mode=0 THEN 
1776      PRINT TABXY(Xp+Xof,Yp+Yof2);"CONFIG MODE : NORMAL"
1777      OUTPUT Dstr$ USING "17X,10A,8X,10A";"BIAS STATE","BIAS PORT"
1778      PRINT TABXY(Xp+Xof,Yp+Yof3);Dstr$
1779      FOR Card_no=1 TO Max_card_no
1780        Rows=(Card_no-1)+Row_offset
1781        SELECT Card_info$(Card_no)
1782        CASE No_card$
1783          OUTPUT Dstr$ USING "6A,10A";"CARD"&VAL$(Card_no),"["&No_card$&"]"
1784          PRINT TABXY(Xp+Xof,Rows);Dstr$
1785        CASE Card_type$(1)
1786          GOSUB Bias_disp_set
1787          OUTPUT Dstr$ USING "6A,10A,5X,3A,15X,3A";"CARD"&VAL$(Card_no),"["&Card_type$(1)&"]",Bias_stat_str$,Bias_port_str$
1788          PRINT TABXY(Xp+Xof,Rows);Dstr$
1789        CASE Card_type$(2)
1790          GOSUB Bias_disp_set
1791          OUTPUT Dstr$ USING "6A,10A,5X,3A,15X,3A";"CARD"&VAL$(Card_no),"["&Card_type$(2)&"]",Bias_stat_str$,Bias_port_str$
1792          PRINT TABXY(Xp+Xof,Rows);Dstr$
1793        CASE ELSE
1794        END SELECT
1795      NEXT Card_no
1796    ELSE
1797      PRINT TABXY(Xp+Xof,Yp+Yof2);"CONFIG MODE : AUTO  "
1798      OUTPUT Dstr$ USING "17X,10A,8X,10A";"BIAS STATE","BIAS PORT"
1799      PRINT TABXY(Xp+Xof,Yp+Yof3);Dstr$
1800      Card_no=0
1801      SELECT Card_info$(Card_no)
1802      CASE No_card$
1803        OUTPUT Dstr$ USING "6A,10A";"CARD"&VAL$(Card_no),"["&No_card$&"]"
1804        PRINT TABXY(Xp+Xof,Rows);Dstr$
1805      CASE Card_type$(1)
1806        GOSUB Bias_disp_set
1807        OUTPUT Dstr$ USING "6A,10A,5X,3A,15X,3A";"CARD"&VAL$(Card_no),"["&Card_type$(1)&"]",Bias_stat_str$,Bias_port_str$
1808        PRINT TABXY(Xp+Xof,Rows);Dstr$
1809      CASE Card_type$(2)
1810        GOSUB Bias_disp_set
1811        OUTPUT Dstr$ USING "6A,10A,5X,3A,15X,3A";"CARD"&VAL$(Card_no),"["&Card_type$(2)&"]",Bias_stat_str$,Bias_port_str$
1812        PRINT TABXY(Xp+Xof,Rows);Dstr$
1813      CASE ELSE
1814      END SELECT
1815    END IF
1816    PRINT TABXY(Xp+Xof,Yp+Yof4);"!! CAUTION !!"
1817    PRINT TABXY(Xp+Xof,Yp+Yof4+1);"  If any setting parameter of this menu is changed,"
1818    PRINT TABXY(Xp+Xof,Yp+Yof4+2);"  all setup memory will be cleared.                "
1819    DISP "Select desired softkey."
1820    SUBEXIT
1821 Bias_disp_set:!
1822    IF Bias_stat(Card_no)=0 THEN 
1823      Bias_stat_str$="OFF"
1824    ELSE
1825      Bias_stat_str$="ON "
1826    END IF
1827    IF Bias_port(Card_no)=-1 THEN 
1828      Bias_port_str$="--"
1829    ELSE
1830      Bias_port_str$=VAL$(Bias_port(Card_no))
1831    END IF
1832    RETURN 
1833  SUBEND
1834  !==========================================================
1835 Bias_data_set:SUB Bias_data_set(Card_no)
1836  !----- Bias data setting ----------------------------------
1837    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1838    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1839    Key_redraw=1
1840    LOOP
1841      IF Key_redraw=1 THEN 
1842        GOSUB Set_fkey
1843      END IF
1844    END LOOP
1845    SUBEXIT
1846 Set_fkey:GOSUB Softkey_clear
1847    Key_redraw=0
1848    ON KEY 1 LABEL " BIAS   STATE ",3 GOSUB B_stat_set_call
1849    SELECT Card_info$(Card_no)
1850    CASE Card_type$(1)
1851      ON KEY 2 LABEL " BIAS   PORT  ",3 GOSUB B_port_set_call
1852    CASE ELSE
1853    END SELECT
1854    ON KEY 7 LABEL " RETURN       ",3 GOTO Bias_data_end
1855    RETURN 
1856 Softkey_clear:!
1857    FOR Key_no=1 TO 8
1858      ON KEY Key_no LABEL "",3 GOSUB Key_null
1859    Key_redraw=1
1860    NEXT Key_no
1861    RETURN 
1862 Key_null:RETURN 
1863 B_stat_set_call:GOSUB Softkey_clear
1864    CALL Bias_stat_set(Card_no)
1865    CALL Setup_mode_menu
1866    RETURN 
1867 B_port_set_call:GOSUB Softkey_clear
1868    CALL Bias_port_set(Card_no)
1869    CALL Setup_mode_menu
1870    RETURN 
1871 Bias_data_end:!
1872  SUBEND
1873  !==========================================================
1874 Bias_stat_set:SUB Bias_stat_set(Card_no)
1875  !----- Bias State Setting ---------------------------------
1876    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1877    Curr_bias_stat=Bias_stat(Card_no)
1878    IF Curr_bias_stat=0 THEN 
1879      Bias_stat(Card_no)=1
1880    ELSE
1881      Bias_stat(Card_no)=0
1882    END IF
1883  SUBEND
1884  !==========================================================
1885 Bias_port_set:SUB Bias_port_set(Card_no)
1886  !----- Bias Port Setting ----------------------------------
1887    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1888    Max_port_num=10
1889    Min_port_num=1
1890    ON ERROR GOTO Input_error
1891 Input_port_num:Port_num$=""
1892    DISP "Input Bias Port Number.";
1893    INPUT " ",Port_num$
1894    IF Port_num$<>"" THEN 
1895      Bias_port_num=VAL(Port_num$)
1896      IF FRACT(Bias_port_num)>0 THEN 
1897        BEEP 
1898        GOTO Input_port_num
1899      END IF
1900      IF Bias_port_num<Min_port_num OR Bias_port_num>Max_port_num THEN 
1901        BEEP 
1902        GOTO Input_port_num
1903      END IF
1904      Bias_port(Card_no)=Bias_port_num
1905    END IF
1906    OFF ERROR 
1907    SUBEXIT
1908 Input_error:BEEP                           !
1909    DISP "*** "&ERRM$
1910    WAIT 1
1911    GOTO Input_port_num
1912  SUBEND
1913  !==========================================================
1914 Setup_chg_check:SUB Setup_chg_check
1915  !----- Check Setup Data changed ---------------------------
1916    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1917    COM /Setup_tmp/ INTEGER Conf_mode_tmp,Bias_stat_tmp(*),Bias_port_tmp(*)
1918    Max_card_no=(SIZE(Bias_stat,1)-1)
1919    IF Conf_mode_tmp<>Config_mode THEN 
1920      GOTO Change_end
1921    ELSE
1922      FOR I=0 TO Max_card_no
1923        B_stat=Bias_stat(I)
1924        B_stat_tmp=Bias_stat_tmp(I)
1925        B_port=Bias_port(I)
1926        B_port_tmp=Bias_port_tmp(I)
1927        IF B_stat<>B_stat_tmp THEN Change_end
1928        IF B_port<>B_port_tmp THEN Change_end
1929      NEXT I
1930    END IF
1931    SUBEXIT
1932 Change_end:CALL Setup_change
1933  SUBEND
1934  !==========================================================
1935 Setup_change:SUB Setup_change
1936  !----- Setup Change New Data ------------------------------
1937    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
1938    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
1939    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
1940    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
1941    COM /Setup_tmp/ INTEGER Conf_mode_tmp,Bias_stat_tmp(*),Bias_port_tmp(*)
1942    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
1943    INTEGER Diff_n
1944    GOSUB Set_fkey
1945    DISP "Changing mode will clear all setup memory. OK?"
1946    LOOP
1947    END LOOP
1948    SUBEXIT
1949 Set_fkey:!
1950    FOR Key_no=1 TO 8
1951      ON KEY Key_no LABEL "",3 GOSUB Key_null
1952    NEXT Key_no
1953    ON KEY 1 LABEL " CHANGE MODE  ",3 GOTO Change_mode
1954    ON KEY 7 LABEL " CANCEL       ",3 GOTO Cancel
1955    RETURN 
1956 Key_null:RETURN 
1957 Change_mode:CALL All_setup_clear
1958    IF Config_mode<>Conf_mode_tmp THEN 
1959      IF Config_mode=0 THEN 
1960        Confm$="NCON"
1961      ELSE
1962        Confm$="ACON"
1963      END IF
1964      OUTPUT @Hp5250;":ROUT:FUNC "&Confm$
1965    END IF
1966    IF Config_mode=0 THEN 
1967      FOR Card_no=1 TO (SIZE(Bias_stat,1)-1)
1968        IF Card_info$(Card_no)<>No_card$ THEN 
1969          OUTPUT @Hp5250;":ROUT:BIAS:STAT "&VAL$(Card_no)&","&VAL$(Bias_stat(Card_no))
1970          SELECT Card_info$(Card_no)
1971          CASE Card_type$(1)
1972            OUTPUT @Hp5250;":ROUT:BIAS:PORT "&VAL$(Card_no)&","&VAL$(Bias_port(Card_no))
1973          CASE ELSE
1974          END SELECT
1975        END IF
1976      NEXT Card_no
1977    ELSE
1978      Card_no=0
1979      OUTPUT @Hp5250;":ROUT:BIAS:STAT "&VAL$(Card_no)&","&VAL$(Bias_stat(Card_no))
1980      SELECT Card_info$(Card_no)
1981      CASE Card_type$(1)
1982        OUTPUT @Hp5250;":ROUT:BIAS:PORT "&VAL$(Card_no)&","&VAL$(Bias_port(Card_no))
1983      CASE ELSE
1984      END SELECT
1985    END IF
1986    OUTPUT @Hp5250;"*OPC?"
1987    ENTER @Hp5250;Cp
1988    Curr_setup_num=1
1989    Err_stat=FNAll_open_set
1990    IF Config_mode=1 THEN CALL Make_block_list(0)  !+++
1991    SUBEXIT
1992 Error_disp:CALL Err_disp
1993    SUBEXIT
1994 Cancel:Config_mode=Conf_mode_tmp
1995    FOR I=0 TO (SIZE(Bias_stat,1)-1)
1996      Bias_stat(I)=Bias_stat_tmp(I)
1997      Bias_port(I)=Bias_port_tmp(I)
1998    NEXT I
1999  SUBEND
2000  !==========================================================
2001 Conf_mode_set:SUB Conf_mode_set
2002  !----- Configuration Mode Change --------------------------
2003    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2004    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2005    COM /Setup_tmp/ INTEGER Conf_mode_tmp,Bias_stat_tmp(*),Bias_port_tmp(*)
2006    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2007    IF Config_mode=0 THEN 
2008      IF Card_info$(0)<>No_card$ THEN 
2009        Config_mode=1
2010      ELSE
2011        BEEP 
2012        DISP "ERROR : card slot #1 is empty."
2013        WAIT 2
2014      END IF
2015    ELSE
2016      Config_mode=0
2017    END IF
2018  SUBEND
2019  !==========================================================
2020 Define_label:SUB Define_label
2021  !----- Define Label ---------------------------------------
2022    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2023    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2024    GOSUB Set_fkey
2025    CALL Def_label_menu
2026    LOOP
2027    END LOOP
2028    GOTO Def_label_end
2029 Set_fkey:!
2030    FOR Key_no=1 TO 8
2031      ON KEY Key_no LABEL "",2 GOSUB Key_null
2032    NEXT Key_no
2033    ON KEY 1 LABEL "E5250A  INPUT ",2 CALL Input_label_set
2034    SELECT Card_info$(1)
2035    CASE Card_type$(2)
2036      ON KEY 2 LABEL " CARD1  INPUT ",2 GOSUB Bias_label_set1
2037    END SELECT
2038    SELECT Card_info$(2)
2039    CASE Card_type$(2)
2040      ON KEY 3 LABEL " CARD2  INPUT ",2 GOSUB Bias_label_set2
2041    END SELECT
2042    SELECT Card_info$(3)
2043    CASE Card_type$(2)
2044      ON KEY 4 LABEL " CARD3  INPUT ",2 GOSUB Bias_label_set3
2045    END SELECT
2046    SELECT Card_info$(4)
2047    CASE Card_type$(2)
2048      ON KEY 5 LABEL " CARD4  INPUT ",2 GOSUB Bias_label_set4
2049    END SELECT
2050    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Def_label_end
2051    RETURN 
2052 Key_null:RETURN 
2053 Bias_label_set1:CALL Bias_label_set(1)
2054    RETURN 
2055 Bias_label_set2:CALL Bias_label_set(2)
2056    RETURN 
2057 Bias_label_set3:CALL Bias_label_set(3)
2058    RETURN 
2059 Bias_label_set4:CALL Bias_label_set(4)
2060    RETURN 
2061 Def_label_end:CLEAR SCREEN
2062    CALL Main_menu
2063  SUBEND
2064  !==========================================================
2065 Def_label_menu:SUB Def_label_menu
2066  !----- Define Label Main Menu Set -------------------------
2067    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2068    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2069    COM /Label/ Input_label$(*),Bias_label$(*)
2070    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
2071    DIM Dstr$[100]
2072    Xp=X_org
2073    Yp=Y_org
2074    Xof=2
2075    Yof1=2
2076    Row_offset=Yp+4
2077    Max_input=(SIZE(Input_label$,1))
2078    Max_card_no=(SIZE(Card_info$,1)-1)
2079    Max_lb_len=5
2080    Ps1$=""""
2081    Ps2$=""""
2082    CLEAR SCREEN
2083    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
2084    PRINT TABXY(Xp,Yp+Yof1);"** DEFINE LABEL MENU **"
2085    PRINT 
2086    FOR Inp_no=1 TO Max_input
2087      Rows=Inp_no+Row_offset
2088      Label$=Input_label$(Inp_no)
2089      CALL Label_format(Label$,Max_lb_len,"C",Ps1$,Ps2$)
2090      IF Inp_no=1 THEN 
2091        OUTPUT Dstr$ USING "7A,7A,3A,10A";"E5250A ","INPUT"&VAL$(Inp_no)," : ",Label$
2092        PRINT TABXY(Xp+Xof,Rows);Dstr$
2093      ELSE
2094        OUTPUT Dstr$ USING "7A,7A,3A,10A";"       ","INPUT"&VAL$(Inp_no)," : ",Label$
2095        PRINT TABXY(Xp+Xof,Rows);Dstr$
2096      END IF
2097    NEXT Inp_no
2098    Row_offset=Rows+1
2099    FOR Card_no=1 TO Max_card_no
2100      Rows=Card_no+Row_offset
2101      SELECT Card_info$(Card_no)
2102      CASE Card_type$(2)
2103        Label1$=Bias_label$(Card_no,1)
2104        CALL Label_format(Label1$,Max_lb_len,"C",Ps1$,Ps2$)
2105        Label2$=Bias_label$(Card_no,2)
2106        CALL Label_format(Label2$,Max_lb_len,"C",Ps1$,Ps2$)
2107        Label3$=Bias_label$(Card_no,3)
2108        CALL Label_format(Label3$,Max_lb_len,"C",Ps1$,Ps2$)
2109        OUTPUT Dstr$ USING "7A,7A,6A,8A,6A,8A,6A,8A";"CARD"&VAL$(Card_no),Card_info$(Card_no)&"A","BIAS1:",Label1$,"BIAS2:",Label2$,"BIAS3:",Label3$
2110        PRINT TABXY(Xp+Xof,Rows);Dstr$
2111      CASE Card_type$(1)
2112        OUTPUT Dstr$ USING "7A,7A,K";"CARD"&VAL$(Card_no),Card_info$(Card_no)&"A","- No Bias Input Port -"
2113        PRINT TABXY(Xp+Xof,Rows);Dstr$
2114      CASE ELSE
2115        OUTPUT Dstr$ USING "7A,7A,K";"CARD"&VAL$(Card_no)," "," "
2116        PRINT TABXY(Xp+Xof,Rows);Dstr$
2117      END SELECT
2118    NEXT Card_no
2119    DISP "Select desired softkey."
2120  SUBEND
2121  !==========================================================
2122 Input_label_set:SUB Input_label_set
2123  !----- Input Label Set menu display -----------------------
2124    Key_redraw=1
2125    Fkey=1
2126    LOOP
2127      IF Key_redraw=1 THEN 
2128        IF Fkey=1 THEN 
2129          GOSUB Set_fkey1
2130        ELSE
2131          GOSUB Set_fkey2
2132        END IF
2133      END IF
2134    END LOOP
2135    SUBEXIT
2136 Set_fkey1:GOSUB Softkey_clear
2137    Fkey=1
2138    Key_redraw=0
2139    ON KEY 1 LABEL "INPUT1  LABEL ",3 GOSUB Input_label1
2140    ON KEY 2 LABEL "INPUT2  LABEL ",3 GOSUB Input_label2
2141    ON KEY 3 LABEL "INPUT3  LABEL ",3 GOSUB Input_label3
2142    ON KEY 4 LABEL "INPUT4  LABEL ",3 GOSUB Input_label4
2143    ON KEY 5 LABEL "INPUT5  LABEL ",3 GOSUB Input_label5
2144    ON KEY 6 LABEL " MORE         ",3 GOSUB Set_fkey2
2145    ON KEY 7 LABEL " RETURN       ",3 GOTO Frame_label_end
2146    RETURN 
2147 Set_fkey2:GOSUB Softkey_clear
2148    Fkey=2
2149    Key_redraw=0
2150    ON KEY 1 LABEL "INPUT6  LABEL ",3 GOSUB Input_label6
2151    ON KEY 2 LABEL "INPUT7  LABEL ",3 GOSUB Input_label7
2152    ON KEY 3 LABEL "INPUT8  LABEL ",3 GOSUB Input_label8
2153    ON KEY 4 LABEL "INPUT9  LABEL ",3 GOSUB Input_label9
2154    ON KEY 5 LABEL "INPUT10 LABEL ",3 GOSUB Input_label10
2155    ON KEY 6 LABEL " MORE         ",3 GOSUB Set_fkey1
2156    ON KEY 7 LABEL " RETURN       ",3 GOTO Frame_label_end
2157    RETURN 
2158 Softkey_clear:!
2159    Key_redraw=1
2160    FOR Key_no=1 TO 8
2161      ON KEY Key_no LABEL "",3 GOSUB Key_null
2162    NEXT Key_no
2163    RETURN 
2164 Key_null:RETURN 
2165 Input_label1:GOSUB Softkey_clear
2166    CALL Input_label(0,0,1)
2167    CALL Def_label_menu
2168    RETURN 
2169 Input_label2:GOSUB Softkey_clear
2170    CALL Input_label(0,0,2)
2171    CALL Def_label_menu
2172    RETURN 
2173 Input_label3:GOSUB Softkey_clear
2174    CALL Input_label(0,0,3)
2175    CALL Def_label_menu
2176    RETURN 
2177 Input_label4:GOSUB Softkey_clear
2178    GOSUB Softkey_clear
2179    CALL Input_label(0,0,4)
2180    CALL Def_label_menu
2181    RETURN 
2182 Input_label5:GOSUB Softkey_clear
2183    CALL Input_label(0,0,5)
2184    CALL Def_label_menu
2185    RETURN 
2186 Input_label6:GOSUB Softkey_clear
2187    CALL Input_label(0,0,6)
2188    CALL Def_label_menu
2189    RETURN 
2190 Input_label7:GOSUB Softkey_clear
2191    CALL Input_label(0,0,7)
2192    CALL Def_label_menu
2193    RETURN 
2194 Input_label8:GOSUB Softkey_clear
2195    CALL Input_label(0,0,8)
2196    CALL Def_label_menu
2197    RETURN 
2198 Input_label9:GOSUB Softkey_clear
2199    CALL Input_label(0,0,9)
2200    CALL Def_label_menu
2201    RETURN 
2202 Input_label10:GOSUB Softkey_clear
2203    CALL Input_label(0,0,10)
2204    CALL Def_label_menu
2205    RETURN 
2206 Frame_label_end:!
2207  SUBEND
2208  !==========================================================
2209 Input_label:SUB Input_label(Bias_no,Card_no,Inp_no)
2210  !----- Label Name Input -----------------------------------
2211    COM /Label/ Input_label$(*),Bias_label$(*)
2212    DIM Label_name$[100]
2213    Max_char=5
2214    ON ERROR GOTO Label_input
2215 Label_input:Label_name$=""
2216    DISP "Input Label Name. (Max "&VAL$(Max_char)&"char string)";
2217    INPUT " ",Label_name$
2218    IF LEN(Label_name$)>Max_char THEN Label_err
2219    IF Bias_no=0 THEN 
2220      Input_label$(Inp_no)=Label_name$
2221    ELSE
2222      Bias_label$(Card_no,Bias_no)=Label_name$
2223    END IF
2224    OFF ERROR 
2225    SUBEXIT
2226 Label_err:BEEP 
2227    GOTO Label_input
2228  SUBEND
2229  !==========================================================
2230 Bias_label_set:SUB Bias_label_set(Card_no)
2231  !----- Bias Label Set -------------------------------------
2232    Key_redraw=1
2233    LOOP
2234      IF Key_redraw=1 THEN 
2235        GOSUB Set_fkey
2236      END IF
2237    END LOOP
2238    SUBEXIT
2239 Set_fkey:GOSUB Softkey_clear
2240    Key_redraw=0
2241    ON KEY 1 LABEL " BIAS1  LABEL ",3 GOSUB Bias1_label
2242    ON KEY 2 LABEL " BIAS2  LABEL ",3 GOSUB Bias2_label
2243    ON KEY 3 LABEL " BIAS3  LABEL ",3 GOSUB Bias3_label
2244    ON KEY 7 LABEL " RETURN       ",3 GOTO Bias_label_end
2245    RETURN 
2246 Softkey_clear:!
2247    Key_redraw=1
2248    FOR Key_no=1 TO 8
2249      ON KEY Key_no LABEL "",3 GOSUB Key_null
2250    NEXT Key_no
2251    RETURN 
2252 Key_null:RETURN 
2253 Bias1_label:GOSUB Softkey_clear
2254    CALL Input_label(1,Card_no,0)
2255    CALL Def_label_menu
2256    RETURN 
2257 Bias2_label:GOSUB Softkey_clear
2258    CALL Input_label(2,Card_no,0)
2259    CALL Def_label_menu
2260    RETURN 
2261 Bias3_label:GOSUB Softkey_clear
2262    CALL Input_label(3,Card_no,0)
2263    CALL Def_label_menu
2264    RETURN 
2265 Bias_label_end:!
2266  SUBEND
2267  !==========================================================
2268 Label_format:SUB Label_format(Label$,Max_len,Form_fg$,Ps1$,Ps2$)
2269  !----- Label format ---------------------------------------
2270    Label$=TRIM$(Label$)
2271    Lb_len=LEN(Label$)
2272    IF Lb_len<Max_len THEN 
2273      SELECT Form_fg$
2274      CASE "L"
2275        Label$=Label$&RPT$(" ",Max_len-Lb_len)
2276      CASE "R"
2277        Label$=RPT$(" ",Max_len-Lb_len)&Label$
2278      CASE "C"
2279        Sp_len1=((Max_len-Lb_len) DIV 2)
2280        Sp_len2=(Max_len-Lb_len)-Sp_len1
2281        Label$=RPT$(" ",Sp_len1)&Label$&RPT$(" ",Sp_len2)
2282      CASE ELSE
2283      END SELECT
2284    END IF
2285    Label$=Ps1$&Label$&Ps2$
2286  SUBEND
2287  !==========================================================
2288 Setup_memory:SUB Setup_memory
2289  !----- Setup Memory Main Routin ---------------------------
2290    GOSUB Softkey_clear
2291    CALL Setup_mem_menu
2292    Fkey=1
2293    Key_redraw=1
2294    LOOP
2295      IF Key_redraw=1 THEN 
2296        IF Fkey=1 THEN 
2297          GOSUB Set_fkey1
2298        ELSE
2299          GOSUB Set_fkey2
2300        END IF
2301      END IF
2302    END LOOP
2303    GOTO Setup_mem_end
2304 Set_fkey1:GOSUB Softkey_clear
2305    Fkey=1
2306    Key_redraw=0
2307    ON KEY 1 LABEL " NEXT   SETUP ",2 GOSUB Next_setup_set
2308    ON KEY 2 LABEL " PREV   SETUP ",2 GOSUB Prev_setup_set
2309    ON KEY 3 LABEL " GOTO   SETUP ",2 GOSUB Goto_setup_set
2310    ON KEY 4 LABEL " MODIFY SETUP ",2 GOSUB Setup_pnl_mode
2311    ON KEY 6 LABEL " MORE         ",2 GOSUB Set_fkey2
2312    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Setup_mem_end
2313    RETURN 
2314 Set_fkey2:GOSUB Softkey_clear
2315    Fkey=2
2316    Key_redraw=0
2317    ON KEY 1 LABEL " CLEAR  SETUP ",2 GOSUB Clear_setup_set
2318    ON KEY 2 LABEL " COPY   SETUP ",2 GOSUB Copy_setup_set
2319    ON KEY 3 LABEL "DELETE  SETUP ",2 GOSUB Del_setup_set
2320    ON KEY 4 LABEL "INSERT  SETUP ",2 GOSUB Ins_setup_set
2321    ON KEY 5 LABEL " CLEAR   ALL  ",2 GOSUB Clear_all_set
2322    ON KEY 6 LABEL " MORE         ",2 GOSUB Set_fkey1
2323    ON KEY 7 LABEL " MAIN   MENU  ",2 GOTO Setup_mem_end
2324    RETURN 
2325 Softkey_clear:!
2326    Key_redraw=1
2327    FOR Key_no=1 TO 8
2328      ON KEY Key_no LABEL "",2 GOSUB Key_null
2329    NEXT Key_no
2330    RETURN 
2331 Key_null:RETURN 
2332 Next_setup_set:GOSUB Softkey_clear
2333    CALL Next_prev_setup(1)
2334    CALL Setup_mem_menu
2335    RETURN 
2336 Prev_setup_set:GOSUB Softkey_clear
2337    CALL Next_prev_setup(0)
2338    CALL Setup_mem_menu
2339    RETURN 
2340 Goto_setup_set:GOSUB Softkey_clear
2341    CALL Goto_setup
2342    CALL Setup_mem_menu
2343    RETURN 
2344 Setup_pnl_mode:GOSUB Softkey_clear
2345    CALL Set_panel_mode
2346    CALL Setup_mem_menu
2347    RETURN 
2348 Clear_setup_set:GOSUB Softkey_clear
2349    CALL Clear_setup
2350    CALL Setup_mem_menu
2351    RETURN 
2352 Copy_setup_set:GOSUB Softkey_clear
2353    CALL Copy_setup
2354    CALL Setup_mem_menu
2355    RETURN 
2356 Del_setup_set:GOSUB Softkey_clear
2357    CALL Delete_setup
2358    CALL Setup_mem_menu
2359    RETURN 
2360 Ins_setup_set:GOSUB Softkey_clear
2361    CALL Insert_setup
2362    CALL Setup_mem_menu
2363    RETURN 
2364 Clear_all_set:GOSUB Softkey_clear
2365    CALL Clear_all_setup
2366    CALL Setup_mem_menu
2367    RETURN 
2368 Setup_mem_end:CLEAR SCREEN
2369    CALL Main_menu
2370  SUBEND
2371  !==========================================================
2372 Setup_mem_menu:SUB Setup_mem_menu
2373  !----- Setup Memory Main Menu -----------------------------
2374    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2375    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
2376    DIM Dstr$[100]
2377    DIM Comstr1$[20],Comstr2$[20]
2378    Xp=X_org
2379    Yp=Y_org
2380    Xof=2
2381    Yof1=2
2382    Yof2=4
2383    Yof3=7
2384    Row_offset=Yp+7
2385    Max_comm_num=SIZE(Setup_comm$,1)
2386    CLEAR SCREEN
2387    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
2388    PRINT TABXY(Xp,Yp+Yof1);"** SETUP MEMORY MENU **"
2389    PRINT TABXY(Xp+Xof,Yp+Yof2);"Current Setup Memory : "&VAL$(Curr_setup_num)&"   "
2390    OUTPUT Dstr$ USING "5A,2A,21A,5A,2A,21A";"Setup",": ","Comment","Setup",": ","Comment"
2391    PRINT TABXY(Xp+Xof,Yp+Yof3);Dstr$
2392    Sp=(Max_comm_num MOD 2)
2393    Offset=(Max_comm_num DIV 2)+Sp
2394    FOR I=1 TO Offset
2395      Rows=Row_offset+I
2396      Comstr1$=Setup_comm$(I)
2397      IF I=Offset AND Sp=1 THEN 
2398        Comstr2$=" "
2399      ELSE
2400        Comstr2$=Setup_comm$(I+Offset)
2401      END IF
2402      OUTPUT Dstr$ USING "1X,2D,2X,2A,21A,1X,2D,2X,2A,21A";I,": ",Comstr1$,(I+Offset),": ",Comstr2$
2403      PRINT TABXY(Xp+Xof,Rows);Dstr$
2404    NEXT I
2405    DISP "Select desired softkey."
2406  SUBEND
2407  !==========================================================
2408 Next_prev_setup:SUB Next_prev_setup(INTEGER Up)
2409  !----- Next/Prev Setup Memory Select ----------------------
2410    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2411    Max_setup_num=SIZE(Setup_mem$,1)
2412    IF Up=1 THEN 
2413      IF Curr_setup_num=Max_setup_num THEN 
2414        Curr_setup_num=1
2415      ELSE
2416        Curr_setup_num=Curr_setup_num+1
2417      END IF
2418    ELSE
2419      IF Curr_setup_num=1 THEN 
2420        Curr_setup_num=Max_setup_num
2421      ELSE
2422        Curr_setup_num=Curr_setup_num-1
2423      END IF
2424    END IF
2425    CALL Hp5250_setup
2426  SUBEND
2427  !==========================================================
2428 Goto_setup:SUB Goto_setup
2429  !----- Jump Setup Memory ----------------------------------
2430    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2431    INTEGER Setup_n
2432    Max_setup_num=SIZE(Setup_mem$,1)
2433    Setup_n=FNInput_setup_num(Max_setup_num,"Input setup memory number to be connected?")
2434    IF Setup_n>0 AND Setup_n<>Curr_setup_num THEN 
2435      Curr_setup_num=Setup_n
2436      CALL Hp5250_setup
2437    END IF
2438  SUBEND
2439  !==========================================================
2440 Clear_setup:SUB Clear_setup
2441  !----- Clear Setup Memory ---------------------------------
2442    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2443    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2444    INTEGER Setup_n,Diff_n,Dfn
2445    Max_setup_num=SIZE(Setup_mem$,1)
2446    Setup_n=FNInput_setup_num(Max_setup_num,"Input setup memory number to be cleared? ENTER to cancel.")
2447    IF Setup_n>0 THEN 
2448      CALL Setup_clear(Setup_n)
2449      IF Setup_n=Curr_setup_num THEN 
2450        Err1=FNAll_open_set
2451        Err2=FNAll_enabl_set
2452      END IF
2453    END IF
2454  SUBEND
2455  !==========================================================
2456 Copy_setup:SUB Copy_setup
2457  !----- Copy Setup Memory ----------------------------------
2458    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2459    Max_setup_num=SIZE(Setup_mem$,1)
2460    ON ERROR GOTO Input_error
2461 Input_num:Src_num$=""
2462    Dest_num$=""
2463    DISP "Input copy src & dest setup memory number: src,dest ";
2464    INPUT " ",Src_num$,Dest_num$
2465    IF Src_num$<>"" AND Dest_num$<>"" THEN 
2466      Src_n=VAL(Src_num$)
2467      Dest_n=VAL(Dest_num$)
2468      IF FRACT(Src_n)>0 THEN 
2469        BEEP 
2470        GOTO Input_num
2471      END IF
2472      IF FRACT(Dest_n)>0 THEN 
2473        BEEP 
2474        GOTO Input_num
2475      END IF
2476      IF Src_n>Max_setup_num OR Src_n<1 THEN 
2477        BEEP 
2478        GOTO Input_num
2479      ELSE
2480        IF Dest_n>Max_setup_num OR Dest_n<1 THEN 
2481          BEEP 
2482          GOTO Input_num
2483        ELSE
2484          IF Src_n=Dest_n THEN 
2485            GOTO End_sub
2486          ELSE
2487            CALL Copy_setmem(Src_n,Dest_n)
2488            IF Dest_n=Curr_setup_num THEN 
2489              CALL Hp5250_setup
2490            END IF
2491          END IF
2492        END IF
2493      END IF
2494    END IF
2495    GOTO End_sub
2496 Input_error:BEEP 
2497    DISP "*** "&ERRM$
2498    WAIT 1
2499    GOTO Input_num
2500 End_sub:OFF ERROR 
2501  SUBEND
2502  !==========================================================
2503 Delete_setup:SUB Delete_setup
2504  !----- Delete Setup Memory --------------------------------
2505    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2506    INTEGER Setup_n
2507    Max_setup_num=SIZE(Setup_mem$,1)
2508    Setup_n=FNInput_setup_num(Max_setup_num,"Input setup memory number to be deleted? ENTER to cancel.")
2509    IF Setup_n>0 THEN 
2510      CALL Sift_setmem(Setup_n,0)
2511      IF Setup_n<=Curr_setup_num THEN 
2512        CALL Hp5250_setup
2513      END IF
2514    END IF
2515  SUBEND
2516  !==========================================================
2517 Insert_setup:SUB Insert_setup
2518  !----- Insert Setup Memory --------------------------------
2519    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2520    INTEGER Setup_n
2521    Max_setup_num=SIZE(Setup_mem$,1)
2522    Setup_n=FNInput_setup_num(Max_setup_num,"Input setup memory number to be inserted? ENTER to cancel.")
2523    IF Setup_n>0 THEN 
2524      CALL Sift_setmem(Setup_n,1)
2525      IF Setup_n<=Curr_setup_num THEN 
2526        CALL Hp5250_setup
2527      END IF
2528    END IF
2529  SUBEND
2530  !==========================================================
2531 Clear_all_setup:SUB Clear_all_setup
2532  !----- Clear All Setup Memory -----------------------------
2533    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2534    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2535    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2536    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2537    INTEGER Diff_n,Dfn
2538    GOSUB Set_fkey
2539    DISP "Clear all setup memory. OK?";
2540    LOOP
2541    END LOOP
2542    GOTO End_sub
2543 Set_fkey:!
2544    FOR Key_no=1 TO 8
2545      ON KEY Key_no LABEL "",3 GOSUB Key_null
2546    NEXT Key_no
2547    ON KEY 1 LABEL " CLEAR  ALL   ",3 GOTO Clear_all
2548    ON KEY 7 LABEL " CANCEL       ",3 GOTO End_sub
2549    RETURN 
2550 Key_null:RETURN 
2551 Clear_all:CALL All_setup_clear
2552    Err1=FNAll_open_set
2553    Err2=FNAll_enabl_set
2554    IF Config_mode=1 THEN 
2555      Card_data_set(0,Curr_setup_num)
2556    ELSE
2557      FOR Card_n=1 TO (SIZE(Setup_mem$,2))
2558        IF Card_info$(Card_n)<>No_card$ THEN 
2559          Card_data_set(Card_n,Curr_setup_num)
2560        END IF
2561      NEXT Card_n
2562    END IF
2563 End_sub:!
2564  SUBEND
2565  !==========================================================
2566 Hp5250_setup:SUB Hp5250_setup
2567  !----- E5250A Switch Setup -----------------------------
2568    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
2569    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2570    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2571    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2572    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2573    COM /Ctrldata/ Chan_list$
2574    INTEGER Diff_n,Dfn
2575    DIM Chan_data$[10],Dis_ch$[500],Enb_ch$[3000],Clos_ch$[3000]
2576    Max_card_no=(SIZE(Card_info$,1)-1)
2577    Diff_n=0
2578    Err=FNAll_open_set
2579    IF Config_mode=0 THEN 
2580      FOR Card_no=1 TO Max_card_no
2581        SELECT Card_info$(Card_no)
2582        CASE Card_type$(1)
2583          CALL E5252_n_setup(Card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2584          IF Dis_n>0 THEN 
2585            GOSUB Out_disable
2586          END IF
2587          IF Enb_n>0 THEN 
2588            GOSUB Out_enable
2589          END IF
2590          IF Clos_n>0 THEN 
2591            GOSUB Out_close
2592          END IF
2593        CASE Card_type$(2)
2594          CALL E5255_n_setup(Card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2595          IF Dis_n>0 THEN 
2596            GOSUB Out_disable
2597          END IF
2598          IF Enb_n>0 THEN 
2599            GOSUB Out_enable
2600          END IF
2601          IF Clos_n>0 THEN 
2602            GOSUB Out_close
2603          END IF
2604        CASE ELSE
2605        END SELECT
2606      NEXT Card_no
2607    ELSE
2608      Max_card_no=FNCont_same_card(Card_info$(0))
2609      IF Max_card_no>0 THEN 
2610        SELECT Card_info$(0)
2611        CASE Card_type$(1)
2612          CALL E5252_a_setup(Max_card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2613          IF Dis_n>0 THEN 
2614            GOSUB Out_disable
2615          END IF
2616          IF Enb_n>0 THEN 
2617            GOSUB Out_enable
2618          END IF
2619          IF Clos_n>0 THEN 
2620            GOSUB Out_close
2621          END IF
2622        CASE Card_type$(2)
2623          CALL E5255_a_setup(Max_card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2624          IF Dis_n>0 THEN 
2625            GOSUB Out_disable
2626          END IF
2627          IF Enb_n>0 THEN 
2628            GOSUB Out_enable
2629          END IF
2630          IF Clos_n>0 THEN 
2631            GOSUB Out_close
2632          END IF
2633        CASE ELSE
2634        END SELECT
2635      ELSE
2636      END IF
2637    END IF
2638    SUBEXIT
2639 Out_close:                                                   !
2640    OUTPUT @Hp5250;":ROUT:CLOS "&Clos_ch$
2641    OUTPUT @Hp5250;"*OPC?"
2642    ENTER @Hp5250;Cp
2643    RETURN 
2644 Out_disable:                                                 !
2645    OUTPUT @Hp5250;":ROUT:BIAS:CHAN:DIS "&Dis_ch$
2646    OUTPUT @Hp5250;"*OPC?"
2647    ENTER @Hp5250;Cp
2648    RETURN 
2649 Out_enable:                                                  !
2650    OUTPUT @Hp5250;":ROUT:BIAS:CHAN:ENAB "&Enb_ch$
2651    OUTPUT @Hp5250;"*OPC?"
2652    ENTER @Hp5250;Cp
2653    RETURN 
2654  SUBEND
2655  !==========================================================
2656 E5252_n_setup:SUB E5252_n_setup(Card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2657  !----- E5252 Normal config mode setup ---------------------
2658    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2659    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2660    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2661    Opend$="."
2662    Closed$="@"
2663    Bias_dis$="-"
2664    C_type$=FNCard_data_query$(Card_no,Max_inp_no,Max_out_no)
2665    Bias_stat_data=Bias_stat(Card_no)
2666    Bias_port_num=Bias_port(Card_no)
2667    Dis_n=0
2668    Enb_n=0
2669    Clos_n=0
2670    Dis_ch$="(@"
2671    Enb_ch$="(@"
2672    Clos_ch$="(@"
2673    FOR Inp_no=1 TO Max_inp_no
2674      FOR Out_no=1 TO Max_out_no
2675        Chan_stat$=Setup_mem$(Curr_setup_num,Card_no,Inp_no)[Out_no;1]
2676        IF Inp_no=Bias_port_num AND Bias_stat_data=1 THEN 
2677          IF Chan_stat$=Bias_dis$ THEN 
2678            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,Inp_no,Out_no,","
2679            Dis_ch$=Dis_ch$&Chan_data$
2680            Dis_n=Dis_n+1
2681          ELSE
2682            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,Inp_no,Out_no,","
2683            Enb_ch$=Enb_ch$&Chan_data$
2684            Enb_n=Enb_n+1
2685          END IF
2686        ELSE
2687          IF Chan_stat$=Closed$ THEN 
2688            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,Inp_no,Out_no,","
2689            Clos_ch$=Clos_ch$&Chan_data$
2690            Clos_n=Clos_n+1
2691          END IF
2692        END IF
2693      NEXT Out_no
2694    NEXT Inp_no
2695    IF Dis_n>0 THEN Dis_ch$[(LEN(Dis_ch$))]=")"
2696    IF Enb_n>0 THEN Enb_ch$[(LEN(Enb_ch$))]=")"
2697    IF Clos_n>0 THEN Clos_ch$[(LEN(Clos_ch$))]=")"
2698  SUBEND
2699  !==========================================================
2700 E5252_a_setup:SUB E5252_a_setup(Max_card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2701  !----- E5252 Auto configuration mode setup -----------------
2702    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2703    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2704    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2705    Opend$="."
2706    Closed$="@"
2707    Bias_dis$="-"
2708    Card0=0
2709    C_type$=FNCard_data_query$(Card0,Max_inp_no,Max_out_no)
2710    Out_offset=Max_out_no
2711    Bias_stat_data=Bias_stat(Card0)
2712    Bias_port_num=Bias_port(Card0)
2713    Dis_n=0
2714    Enb_n=0
2715    Clos_n=0
2716    Dis_ch$="(@"
2717    Enb_ch$="(@"
2718    Clos_ch$="(@"
2719    FOR Card_no=1 TO Max_card_no
2720      Offset_num=(Card_no-1)*Out_offset
2721      FOR Inp_no=1 TO Max_inp_no
2722        FOR Out_no=1 TO Max_out_no
2723          Chan_stat$=Setup_mem$(Curr_setup_num,Card_no,Inp_no)[Out_no;1]
2724          IF Inp_no=Bias_port_num AND Bias_stat_data=1 THEN 
2725            IF Chan_stat$=Bias_dis$ THEN 
2726              OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,Inp_no,(Out_no+Offset_num),","
2727              Dis_ch$=Dis_ch$&Chan_data$
2728              Dis_n=Dis_n+1
2729            ELSE
2730              OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,Inp_no,(Out_no+Offset_num),","
2731              Enb_ch$=Enb_ch$&Chan_data$
2732              Enb_n=Enb_n+1
2733            END IF
2734          ELSE
2735            IF Chan_stat$=Closed$ THEN 
2736              OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,Inp_no,(Out_no+Offset_num),","
2737              Clos_ch$=Clos_ch$&Chan_data$
2738              Clos_n=Clos_n+1
2739            END IF
2740          END IF
2741        NEXT Out_no
2742      NEXT Inp_no
2743    NEXT Card_no
2744    IF Dis_n>0 THEN Dis_ch$[(LEN(Dis_ch$))]=")"
2745    IF Enb_n>0 THEN Enb_ch$[(LEN(Enb_ch$))]=")"
2746    IF Clos_n>0 THEN Clos_ch$[(LEN(Clos_ch$))]=")"
2747  SUBEND
2748  !==========================================================
2749 E5255_n_setup:SUB E5255_n_setup(Card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2750  !----- E5255 Normal config mode setup ---------------------
2751    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2752    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2753    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2754    Opend$="."
2755    Closed$="@"
2756    Bias_dis$="-"
2757    Bias_ch_num=50
2758    C_type$=FNCard_data_query$(Card_no,Max_inp_no,Max_out_no)
2759    Bias_stat_data=Bias_stat(Card_no)
2760    Dis_n=0
2761    Enb_n=0
2762    Clos_n=0
2763    Dis_ch$="(@"
2764    Enb_ch$="(@"
2765    Clos_ch$="(@"
2766    FOR Inp_no=1 TO Max_inp_no
2767      FOR Out_no=1 TO Max_out_no
2768        Chan_stat$=Setup_mem$(Curr_setup_num,Card_no,Inp_no)[Out_no;1]
2769        IF (Inp_no MOD 2)=0 AND Bias_stat_data=1 THEN 
2770          IF Chan_stat$=Bias_dis$ THEN 
2771            In_num=((Inp_no) DIV 2)+Bias_ch_num
2772            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,In_num,Out_no,","
2773            Dis_ch$=Dis_ch$&Chan_data$
2774            Dis_n=Dis_n+1
2775          ELSE
2776            In_num=((Inp_no) DIV 2)+Bias_ch_num
2777            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,In_num,Out_no,","
2778            Enb_ch$=Enb_ch$&Chan_data$
2779            Enb_n=Enb_n+1
2780          END IF
2781        ELSE
2782          IF Chan_stat$=Closed$ THEN 
2783            IF (Inp_no MOD 2)=0 THEN 
2784              In_num=(Inp_no DIV 2)+Bias_ch_num
2785            ELSE
2786              In_num=((Inp_no-1) DIV 2)+1
2787            END IF
2788            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_no,In_num,Out_no,","
2789            Clos_ch$=Clos_ch$&Chan_data$
2790            Clos_n=Clos_n+1
2791          END IF
2792        END IF
2793      NEXT Out_no
2794    NEXT Inp_no
2795    IF Dis_n>0 THEN Dis_ch$[(LEN(Dis_ch$))]=")"
2796    IF Enb_n>0 THEN Enb_ch$[(LEN(Enb_ch$))]=")"
2797    IF Clos_n>0 THEN Clos_ch$[(LEN(Clos_ch$))]=")"
2798  SUBEND
2799  !==========================================================
2800 E5255_a_setup:SUB E5255_a_setup(Max_card_no,Dis_ch$,Enb_ch$,Clos_ch$,Dis_n,Enb_n,Clos_n)
2801  !----- E5255 Auto configuration mode setup ----------------
2802    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2803    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2804    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2805    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
2806    INTEGER In_port_num(1:4,1:3)
2807    Card0=0
2808    Max_block_col=12
2809    Max_block=3
2810    Bias_ch_num=10
2811    Opend$="."
2812    Closed$="@"
2813    Bias_dis$="-"
2814    B_stat=Bias_stat(0)
2815    C_type$=FNCard_data_query$(Card0,Max_inp_no,Max_out_no)
2816    Out_offset=Max_out_no
2817    Dis_n=0
2818    Enb_n=0
2819    Clos_n=0
2820    Dis_ch$="(@"
2821    Enb_ch$="(@"
2822    Clos_ch$="(@"
2823    FOR Inp_no=1 TO Max_inp_no
2824      FOR Block_col=1 TO Max_block_col
2825        Offset_num=Out_offset*(Block_col-1)
2826        Card_no=Block_list(Inp_no,Block_col,1)
2827        Block=Block_list(Inp_no,Block_col,2)
2828        IF Card_no>0 AND Block>0 THEN 
2829          FOR Out_no=1 TO Max_out_no
2830            Chan_stat$=Setup_mem$(Curr_setup_num,Card_no,(Block-1)*2+1)[Out_no;1]
2831            IF Chan_stat$=Closed$ THEN 
2832              In_num=Inp_no
2833              OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,In_num,(Out_no+Offset_num),","
2834              Clos_ch$=Clos_ch$&Chan_data$
2835              Clos_n=Clos_n+1
2836            END IF
2837            Chan_stat$=Setup_mem$(Curr_setup_num,Card_no,(Block-1)*2+2)[Out_no;1]
2838            IF B_stat<>1 THEN 
2839              IF Chan_stat$=Closed$ THEN 
2840                In_num=Inp_no+Bias_ch_num
2841                OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,In_num,(Out_no+Offset_num),","
2842                Clos_ch$=Clos_ch$&Chan_data$
2843                Clos_n=Clos_n+1
2844              END IF
2845            ELSE
2846              IF Chan_stat$=Bias_dis$ THEN 
2847                In_num=Inp_no+Bias_ch_num
2848                OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,In_num,(Out_no+Offset_num),","
2849                Dis_ch$=Dis_ch$&Chan_data$
2850                Dis_n=Dis_n+1
2851              ELSE
2852                In_num=Inp_no+Bias_ch_num
2853                OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,In_num,(Out_no+Offset_num),","
2854                Enb_ch$=Enb_ch$&Chan_data$
2855                Enb_n=Enb_n+1
2856              END IF
2857            END IF
2858          NEXT Out_no
2859        END IF
2860      NEXT Block_col
2861    NEXT Inp_no
2862    IF Dis_n>0 THEN Dis_ch$[(LEN(Dis_ch$))]=")"
2863    IF Enb_n>0 THEN Enb_ch$[(LEN(Enb_ch$))]=")"
2864    IF Clos_n>0 THEN Clos_ch$[(LEN(Clos_ch$))]=")"
2865  SUBEND
2866  !==========================================================
2867 Card_data_query:DEF FNCard_data_query$(Card_no,Max_in,Max_out)
2868  !----- Card IN/OUT information query ----------------------
2869    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2870    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2871    SELECT Card_info$(Card_no)
2872    CASE Card_type$(1)
2873      Max_in=10
2874      Max_out=12
2875      C_type$=Card_type$(1)
2876    CASE Card_type$(2)
2877      Max_in=6
2878      Max_out=8
2879      C_type$=Card_type$(2)
2880    CASE ELSE
2881      Max_in=1
2882      Max_out=1
2883      C_type$=""
2884    END SELECT
2885    RETURN C_type$
2886  FNEND
2887  !==========================================================
2888 Cont_same_card:DEF FNCont_same_card(C_type$)
2889  !----- Continuous same card search ------------------------
2890    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2891    Max_card_slot=(SIZE(Card_info$,1)-1)
2892    Card_no=1
2893    LOOP
2894      Exit_fg=0
2895    EXIT IF Card_no>Max_card_slot
2896      IF C_type$<>Card_info$(Card_no) THEN 
2897        Exit_fg=1
2898      END IF
2899    EXIT IF Exit_fg=1
2900      Card_no=Card_no+1
2901    END LOOP
2902    Max_card_no=Card_no-1
2903    RETURN Max_card_no
2904  FNEND
2905  !==========================================================
2906 Input_setup_num:DEF FNInput_setup_num(Max_setup_num,Message$)
2907  !----- Input Setup Memory number --------------------------
2908    INTEGER Setup_n
2909    ON ERROR GOTO Input_error
2910 Input_num:Setup_num$=""
2911    Setup_n=0
2912    DISP Message$;
2913    INPUT " ",Setup_num$
2914    IF Setup_num$<>"" THEN 
2915      IF FRACT(VAL(Setup_num$))>0 THEN 
2916        BEEP 
2917        GOTO Input_num
2918      END IF
2919      Setup_n=VAL(Setup_num$)
2920      IF Setup_n>Max_setup_num OR Setup_n<1 THEN 
2921        BEEP 
2922        GOTO Input_num
2923      END IF
2924    END IF
2925    OFF ERROR 
2926    RETURN Setup_n
2927 Input_error:BEEP 
2928    DISP "*** "&ERRM$
2929    WAIT 1
2930    GOTO Input_num
2931  FNEND
2932  !==========================================================
2933 Setup_clear:SUB Setup_clear(INTEGER Setup_no)
2934  !----- Setup Memory Clear ---------------------------------
2935    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2936    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2937    Max_card_no=(SIZE(Card_info$,1)-1)
2938    FOR Card_no=1 TO Max_card_no
2939      CALL Setup_clr_card(Setup_no,Card_no,Setup_mem$(*))
2940    NEXT Card_no
2941    Setup_comm$(Setup_no)="Open All"
2942  SUBEND
2943  !==========================================================
2944 Sift_setmem:SUB Sift_setmem(INTEGER Setup_num,Up)
2945  !----- Setup Memory Shift ---------------------------------
2946    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2947    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2948    INTEGER Max_card_no,Max_setup_num
2949    Max_card_no=(SIZE(Card_info$,1)-1)
2950    Max_setup_num=SIZE(Setup_mem$,1)
2951    IF Up=1 THEN 
2952      FOR Set_n=Max_setup_num TO (Setup_num+1) STEP -1
2953        FOR Card_no=1 TO Max_card_no
2954          C_type$=FNCard_data_query$(Card_no,Max_inp_no,Max_out_no)
2955          FOR Inp_no=1 TO Max_inp_no
2956            Setup_mem$(Set_n,Card_no,Inp_no)=Setup_mem$((Set_n-1),Card_no,Inp_no)
2957          NEXT Inp_no
2958        NEXT Card_no
2959        Setup_comm$(Set_n)=Setup_comm$((Set_n-1))
2960      NEXT Set_n
2961      CALL Setup_clear(Setup_num)
2962    ELSE
2963      FOR Set_n=Setup_num TO (Max_setup_num-1) STEP 1
2964        FOR Card_no=1 TO Max_card_no
2965          C_type$=FNCard_data_query$(Card_no,Max_inp_no,Max_out_no)
2966          FOR Inp_no=1 TO Max_inp_no
2967            Setup_mem$(Set_n,Card_no,Inp_no)=Setup_mem$((Set_n+1),Card_no,Inp_no)
2968          NEXT Inp_no
2969        NEXT Card_no
2970        Setup_comm$(Set_n)=Setup_comm$((Set_n+1))
2971      NEXT Set_n
2972      CALL Setup_clear(Max_setup_num)
2973    END IF
2974  SUBEND
2975  !==========================================================
2976 Copy_setmem:SUB Copy_setmem(Src_num,Dest_num)
2977  !----- Copy Setup Memory ----------------------------------
2978    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2979    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2980    Max_card_no=(SIZE(Card_info$,1)-1)
2981    FOR Card_no=1 TO Max_card_no
2982      C_type$=FNCard_data_query$(Card_no,Max_inp_no,Max_out_no)
2983      FOR Inp_no=1 TO Max_inp_no
2984        Setup_mem$(Dest_num,Card_no,Inp_no)=Setup_mem$(Src_num,Card_no,Inp_no)
2985      NEXT Inp_no
2986    NEXT Card_no
2987    Setup_comm$(Dest_num)=Setup_comm$(Src_num)
2988  SUBEND
2989  !==========================================================
2990 Set_panel_mode:SUB Set_panel_mode
2991  !----- Setup Panel Mode -----------------------------------
2992    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
2993    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
2994    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
2995    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
2996    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
2997    INTEGER Diff_n,Port_no,Num_of_out(1:6),Max_column
2998    GOSUB Softkey_clear
2999    IF Config_mode=0 THEN 
3000      Curr_card_num=1
3001      GOSUB Set_card_num
3002      CALL Make_block_list(Curr_card_num)  !+++
3003    ELSE
3004      Curr_card_num=0
3005    END IF
3006    CALL Card_data_set(Curr_card_num,Curr_setup_num)
3007    CALL Set_panel_menu(1)
3008    Key_redraw=1
3009    LOOP
3010      IF Key_redraw=1 THEN 
3011        GOSUB Set_fkey1
3012      END IF
3013    END LOOP
3014    GOTO Set_panel_end
3015 Set_fkey1:GOSUB Softkey_clear
3016    Key_redraw=0
3017    ON KEY 1 LABEL "CHANGE  CHAN  ",3 GOSUB Change_ch_mode
3018    ON KEY 2 LABEL "COMMENT       ",3 GOSUB Comment_set
3019    IF Config_mode=0 THEN 
3020      ON KEY 3 LABEL " NEXT   CARD  ",3 GOSUB Next_card_sel
3021    ELSE
3022      SELECT Card_info$(0)
3023      CASE Card_type$(1)
3024      CASE Card_type$(2)
3025        GOSUB Get_max_column
3026        IF Max_column>Max_disp_col THEN 
3027          ON KEY 3 LABEL " SWITCH PAGE  ",3 GOSUB Next_page_sel
3028        END IF
3029      CASE ELSE
3030      END SELECT
3031    END IF
3032    ON KEY 4 LABEL " NEXT   SETUP ",3 GOSUB Next_setup_sel
3033    ON KEY 5 LABEL " PREV   SETUP ",3 GOSUB Prev_setup_sel
3034    ON KEY 6 LABEL " GOTO   SETUP ",3 GOSUB Goto_setup_sel
3035    ON KEY 7 LABEL " SETUP  MEMORY",3 GOTO Set_panel_end
3036    RETURN 
3037 Softkey_clear:!
3038    Key_redraw=1
3039    FOR Key_no=1 TO 8
3040      ON KEY Key_no LABEL "",3 GOSUB Key_null
3041    NEXT Key_no
3042    RETURN 
3043 Key_null:RETURN 
3044 Change_ch_mode:CALL Cursor_move("C")
3045    CALL Change_chanel
3046    RETURN 
3047 Comment_set:GOSUB Softkey_clear
3048    CALL Setup_comm_set
3049    RETURN 
3050 Next_card_sel:GOSUB Softkey_clear
3051    CALL Next_card_set
3052    CALL Card_data_set(Curr_card_num,Curr_setup_num)
3053    CALL Set_panel_menu(1)
3054    RETURN 
3055 Next_page_sel:GOSUB Softkey_clear
3056    IF Curr_page=1 THEN 
3057      IF Max_col>Max_disp_col THEN 
3058        Curr_page=2
3059      END IF
3060    ELSE
3061      Curr_page=1
3062    END IF
3063    CALL Set_panel_menu(1)
3064    RETURN 
3065 Next_setup_sel:GOSUB Softkey_clear
3066    CALL Next_prev_setup(1)
3067    IF Config_mode=0 THEN 
3068      Curr_card_num=1
3069      GOSUB Set_card_num
3070      CALL Make_block_list(Curr_card_num)  !+++
3071    ELSE
3072      Curr_card_num=0
3073    END IF
3074    CALL Card_data_set(Curr_card_num,Curr_setup_num)
3075    CALL Set_panel_menu(1)
3076    RETURN 
3077 Prev_setup_sel:GOSUB Softkey_clear
3078    CALL Next_prev_setup(0)
3079    IF Config_mode=0 THEN 
3080      Curr_card_num=1
3081      GOSUB Set_card_num
3082      CALL Make_block_list(Curr_card_num)  !+++
3083    ELSE
3084      Curr_card_num=0
3085    END IF
3086    CALL Card_data_set(Curr_card_num,Curr_setup_num)
3087    CALL Set_panel_menu(1)
3088    RETURN 
3089 Goto_setup_sel:GOSUB Softkey_clear
3090    CALL Goto_setup
3091    IF Config_mode=0 THEN 
3092      Curr_card_num=1
3093      GOSUB Set_card_num
3094      CALL Make_block_list(Curr_card_num)  !+++
3095    ELSE
3096      Curr_card_num=0
3097    END IF
3098    CALL Card_data_set(Curr_card_num,Curr_setup_num)
3099    CALL Set_panel_menu(1)
3100    RETURN 
3101 Set_card_num:Max_card_no=(SIZE(Card_info$,1)-1)
3102    IF Card_info$(Curr_card_num)=No_card$ THEN 
3103      Tmp_card_num=Curr_card_num
3104      LOOP
3105        Err_fg=0
3106        Exit_fg=0
3107        Tmp_card_num=Tmp_card_num+1
3108        IF Tmp_card_num>Max_card_no THEN 
3109          Tmp_card_num=1
3110        END IF
3111        IF Tmp_card_num=Curr_card_num THEN 
3112          Err_fg=1
3113          Exit_fg=1
3114        END IF
3115        IF Card_info$(Tmp_card_num)<>No_card$ THEN 
3116          Exit_fg=1
3117        END IF
3118      EXIT IF Exit_fg=1
3119      END LOOP
3120      IF Err_fg=1 THEN 
3121        BEEP 
3122        DISP "ERROR : All Slot is Empty"
3123        WAIT 2
3124        GOTO Set_panel_end
3125      END IF
3126      Curr_card_num=Tmp_card_num
3127    END IF
3128    RETURN 
3129 Get_max_column:MAT Num_of_out= (0)
3130    Max_card_no=FNCont_same_card(Card_type$(2))
3131    FOR Card_no=1 TO Max_card_no
3132      IF Card_info$(Card_no)=Card_type$(2) THEN 
3133        FOR B=1 TO 3
3134          Port_no=VAL(Card_conf$(Card_no)[(B*2)-1;1])
3135          Num_of_out(Port_no)=Num_of_out(Port_no)+8
3136        NEXT B
3137      END IF
3138    NEXT Card_no
3139    Max_column=0
3140    FOR I=1 TO 6
3141      IF Max_column<Num_of_out(I) THEN 
3142        Max_column=Num_of_out(I)
3143      END IF
3144    NEXT I
3145    RETURN 
3146 Set_panel_end:!
3147  SUBEND
3148  !==========================================================
3149 Set_panel_menu:SUB Set_panel_menu(Re_set)
3150  !----- Setup Panel Mode Menu ------------------------------
3151    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3152    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3153    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3154    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3155    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3156    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3157    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3158    DIM Dstr$[100]
3159    Xp=X_org
3160    Yp=Y_org
3161    Xof=2
3162    Yof1=2
3163    Yof2=3
3164    Xy_offset(1,1)=Xp+9
3165    Xy_offset(2,1)=Yp+8
3166    X_off=Xy_offset(1,1)
3167    Y_off=Xy_offset(2,1)
3168    IF (Re_set=1) THEN 
3169      Rows=1
3170      LOOP
3171      EXIT IF Rows>SIZE(Disp_matrix,1)
3172      EXIT IF Disp_matrix(Rows,1)>0
3173        Rows=Rows+1
3174      END LOOP
3175      IF Rows>SIZE(Disp_matrix,1) THEN Rows=1
3176      IF Curr_page=1 THEN 
3177        Cursor_pos(1,1)=1
3178      ELSE
3179        Cursor_pos(1,1)=Max_disp_col+1
3180      END IF
3181      Cursor_pos(2,1)=Rows
3182    END IF
3183    IF Cursor_pos(1,1)>Max_disp_col THEN 
3184      Xy_pos(1,1)=Xy_offset(1,1)+(Cursor_pos(1,1)-Max_disp_col)
3185      Xy_pos(2,1)=Xy_offset(2,1)+Cursor_pos(2,1)
3186    ELSE
3187      Xy_pos(1,1)=Xy_offset(1,1)+Cursor_pos(1,1)
3188      Xy_pos(2,1)=Xy_offset(2,1)+Cursor_pos(2,1)
3189    END IF
3190    CLEAR SCREEN
3191    PRINT TABXY(Xp,Yp);"Agilent E5250A Virtual Front Panel Utility"
3192    PRINT TABXY(Xp,Yp+Yof1);"** MEMORY SETUP PANEL **"
3193    OUTPUT Dstr$ USING "#,24A,21A";"Current Setup Memory : ",VAL$(Curr_setup_num)
3194    PRINT TABXY(Xp+Xof,Yp+Yof2);Dstr$
3195    OUTPUT Dstr$ USING "#,24A,21A";"Comment              : ",Setup_comm$(Curr_setup_num)
3196    PRINT TABXY(Xp+Xof,Yp+Yof2+1);Dstr$
3197    OUTPUT Dstr$ USING "#,24A,21A";"Card Number          : ",VAL$(Curr_card_num)
3198    PRINT TABXY(Xp+Xof,Yp+Yof2+2);Dstr$
3199    IF Config_mode=0 THEN 
3200      SELECT FNCard_data_query$(Curr_card_num,Max_in,Max_out)
3201      CASE Card_type$(1)
3202        CALL Set_panel_n1(Xof)
3203      CASE Card_type$(2)
3204        CALL Set_panel_n2(Xof)
3205      CASE ELSE
3206      END SELECT
3207    ELSE
3208      SELECT FNCard_data_query$(Curr_card_num,Max_in,Max_out)
3209      CASE Card_type$(1)
3210        CALL Set_panel_a1(Xof)
3211      CASE Card_type$(2)
3212        CALL Set_panel_a2(Xof)
3213      CASE ELSE
3214      END SELECT
3215    END IF
3216    DISP "Select desired softkey."
3217  SUBEND
3218  !==========================================================
3219 Set_panel_n1:SUB Set_panel_n1(X_of)
3220  !----- Setup Panel Menu Create (E5252 Normal Config Mode) -
3221    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3222    COM /Label/ Input_label$(*),Bias_label$(*)
3223    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3224    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3225    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3226    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3227    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3228    DIM Dstr$[100]
3229    DIM Ttl_name$[20],Ttl1$[100],Ttl2$[100]
3230    Xp=X_org
3231    Yp=Y_org
3232    X_off=Xy_offset(1,1)
3233    Y_off=Xy_offset(2,1)
3234    Max_row=Max_in
3235    Max_col=Max_out
3236    Ttl1$=""
3237    Ttl2$=""
3238    FOR I=1 TO Max_col
3239      OUTPUT T$ USING "2D";I
3240      Ttl1$=Ttl1$&T$[1;1]
3241      Ttl2$=Ttl2$&T$[2;1]
3242    NEXT I
3243    PRINT TABXY((X_off+1),(Y_off-1));Ttl1$
3244    OUTPUT Ttl_name$ USING "6A,2A";"Input"," "
3245    PRINT TABXY(Xp+X_of,Xy_offset(2,1));Ttl_name$
3246    PRINT TABXY((X_off+1),(Y_off));Ttl2$
3247    Row_offset=Y_off
3248    FOR Inp_no=1 TO Max_in
3249      Rows=Inp_no+Row_offset
3250      IF Disp_matrix(Inp_no,2)=1 THEN 
3251        Bias_str$="*"
3252      ELSE
3253        Bias_str$=" "
3254      END IF
3255      OUTPUT Dstr$ USING "6A,2A";Input_label$(Inp_no),Bias_str$
3256      PRINT TABXY(Xp+X_of,Rows);Dstr$
3257      PRINT TABXY((X_off+1),(Y_off+Inp_no));Setup_mem$(Curr_setup_num,Curr_card_num,Inp_no)
3258    NEXT Inp_no
3259  SUBEND
3260  !==========================================================
3261 Set_panel_n2:SUB Set_panel_n2(X_of)
3262  !----- Setup Panel Menu Create (E5255 Normal Config Mode) -
3263    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3264    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3265    COM /Label/ Input_label$(*),Bias_label$(*)
3266    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3267    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3268    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3269    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3270    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3271    DIM Dstr$[100]
3272    DIM Ttl_name$[20],Ttl1$[100],Ttl2$[100]
3273    DIM In_port_label$(1:3)[5]
3274    INTEGER In_port_num(1:3)
3275    Xp=X_org
3276    Yp=Y_org
3277    X_off=Xy_offset(1,1)
3278    Y_off=Xy_offset(2,1)
3279    Max_row=Max_in
3280    Max_col=Max_out
3281    Max_bias_num=3
3282    Ttl1$=""
3283    Ttl2$=""
3284    FOR I=1 TO Max_col
3285      OUTPUT T$ USING "2D";I
3286      Ttl1$=Ttl1$&T$[1;1]
3287      Ttl2$=Ttl2$&T$[2;1]
3288    NEXT I
3289    PRINT TABXY((X_off+1),(Y_off-1));Ttl1$
3290    OUTPUT Ttl_name$ USING "6A,2A";"Input"," "
3291    PRINT TABXY(Xp+X_of,Y_off);Ttl_name$
3292    PRINT TABXY((X_off+1),(Y_off));Ttl2$
3293    FOR I=1 TO Max_bias_num
3294      In_port_label$(I)=Input_label$(VAL(Card_conf$(Curr_card_num)[(I-1)*2+1;1]))
3295    NEXT I
3296    Row_offset=Y_off
3297    FOR Inp_no=1 TO Max_in
3298      Rows=Inp_no+Row_offset
3299      IF (Inp_no MOD 2)=0 THEN 
3300        IF Disp_matrix(Inp_no,2)=1 THEN 
3301          Bias_str$="*"
3302        ELSE
3303          Bias_str$=" "
3304        END IF
3305        Set_label$=Bias_label$(Curr_card_num,(Inp_no/2))
3306      ELSE
3307        Bias_str$=" "
3308        Set_label$=In_port_label$((Inp_no+1)/2)
3309      END IF
3310      OUTPUT Dstr$ USING "6A,2A";Set_label$,Bias_str$
3311      PRINT TABXY(Xp+X_of,Rows);Dstr$
3312      PRINT TABXY((X_off+1),(Y_off+Inp_no));Setup_mem$(Curr_setup_num,Curr_card_num,Inp_no)
3313    NEXT Inp_no
3314  SUBEND
3315  !==========================================================
3316 Set_panel_a1:SUB Set_panel_a1(X_of)
3317  !----- Setup Panel Menu Create (E5252 Auto Config Mode) ---
3318    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3319    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3320    COM /Label/ Input_label$(*),Bias_label$(*)
3321    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3322    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3323    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3324    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3325    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3326    DIM Dstr$[100]
3327    DIM Ttl_name$[20],Ttl1$[100],Ttl2$[100]
3328    Xp=X_org
3329    Yp=Y_org
3330    X_off=Xy_offset(1,1)
3331    Y_off=Xy_offset(2,1)
3332    Max_slot_no=(SIZE(Card_info$,1)-1)
3333    Max_card_no=FNCont_same_card(Card_type$(1))
3334    Max_inp_no=Max_in
3335    Max_out_no=Max_card_no*Max_out
3336    Max_row=Max_in
3337    Max_col=Max_card_no*Max_out
3338    Ttl1$=""
3339    Ttl2$=""
3340    FOR I=1 TO Max_col
3341      OUTPUT T$ USING "2D";I
3342      Ttl1$=Ttl1$&T$[1;1]
3343      Ttl2$=Ttl2$&T$[2;1]
3344    NEXT I
3345    PRINT TABXY((X_off+1),(Y_off-1));Ttl1$
3346    OUTPUT Ttl_name$ USING "6A,2A";"Input"," "
3347    PRINT TABXY(Xp+X_of,Y_off);Ttl_name$
3348    PRINT TABXY((X_off+1),(Y_off));Ttl2$
3349    Row_offset=Y_off
3350    FOR Inp_no=1 TO Max_inp_no
3351      Rows=Inp_no+Row_offset
3352      IF Disp_matrix(Inp_no,2)=1 THEN 
3353        Bias_str$="*"
3354      ELSE
3355        Bias_str$=" "
3356      END IF
3357      OUTPUT Dstr$ USING "6A,2A";Input_label$(Inp_no),Bias_str$
3358      PRINT TABXY(Xp+X_of,Rows);Dstr$
3359      Sift=1
3360      FOR Card_no=1 TO Max_card_no
3361        PRINT TABXY((X_off+Sift),(Y_off+Inp_no));Setup_mem$(Curr_setup_num,Card_no,Inp_no)
3362        Sift=Sift+Max_out
3363      NEXT Card_no
3364    NEXT Inp_no
3365  SUBEND
3366  !==========================================================
3367 Set_panel_a2:SUB Set_panel_a2(X_of)
3368  !----- Setup Panel Menu Create (E5255 Auto Config Mode) ---
3369    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3370    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3371    COM /Label/ Input_label$(*),Bias_label$(*)
3372    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3373    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3374    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3375    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3376    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3377    DIM Dstr$[100]
3378    DIM Ttl_name$[20],Ttl1$[100],Ttl2$[100]
3379    DIM In_port_label$(1:4,1:3)[5]
3380    INTEGER In_port_num(1:4,1:3)
3381    Xp=X_org
3382    Yp=Y_org
3383    X_off=Xy_offset(1,1)
3384    Y_off=Xy_offset(2,1)
3385    Max_row=Max_in*2
3386    Max_block=3
3387    Max_slot_no=(SIZE(Card_info$,1)-1)
3388    Max_card_no=FNCont_same_card(Card_type$(2))
3389    Bias_stat_num=Bias_stat(Curr_card_num)
3390    !
3391    Max_col=0                                         !++
3392    FOR I=1 TO (SIZE(Disp_matrix,1))                  !++
3393      Tmp_max_col=Disp_matrix(I,1)                    !++
3394      IF Tmp_max_col>Max_col THEN Max_col=Tmp_max_col !++
3395    NEXT I                                            !++
3396    Ttl1$=""
3397    Ttl2$=""
3398    IF Max_col>Max_disp_col THEN 
3399      IF Curr_page=1 THEN 
3400        Disp_col=Max_disp_col
3401      ELSE
3402        Disp_col=Max_col-Max_disp_col
3403      END IF
3404    ELSE
3405      Disp_col=Max_col
3406    END IF
3407    FOR I=1 TO Disp_col
3408      IF Curr_page=1 THEN 
3409        OUTPUT T$ USING "#,2D";I
3410      ELSE
3411        OUTPUT T$ USING "#,2D";(I+Max_disp_col)
3412      END IF
3413      Ttl1$=Ttl1$&T$[1;1]
3414      Ttl2$=Ttl2$&T$[2;1]
3415    NEXT I
3416    PRINT TABXY((X_off+1),(Y_off-1));Ttl1$
3417    OUTPUT Ttl_name$ USING "#,6A,2A";"Input"," "
3418    PRINT TABXY(Xp+X_of,Y_off);Ttl_name$
3419    PRINT TABXY((X_off+1),(Y_off));Ttl2$
3420    Row_offset=Y_off
3421    FOR Inp_no=1 TO Max_in
3422      Rows=((Inp_no-1)*2+1)+Row_offset
3423      IF Max_col>Max_disp_col THEN 
3424        IF Curr_page=1 THEN 
3425          St_block=1
3426          End_block=Max_disp_col/Max_out
3427        ELSE
3428          St_block=Max_disp_col/Max_out+1
3429          End_block=INT((Disp_matrix((Inp_no-1)*2+1,1))/Max_out)
3430        END IF
3431      ELSE
3432        St_block=1
3433        End_block=INT((Disp_matrix((Inp_no-1)*2+1,1))/Max_out)
3434      END IF
3435      Card=Block_list(Inp_no,St_block,1)
3436      Block=Block_list(Inp_no,St_block,2)
3437      IF Card>0 AND Block>0 THEN 
3438        Set_label$=Input_label$(Inp_no)
3439      ELSE
3440        Set_label$=""
3441      END IF
3442      Bias_str$=" "
3443      OUTPUT Dstr$ USING "#,6A,2A";Set_label$,Bias_str$
3444      PRINT TABXY(Xp+X_of,Rows);Dstr$
3445      Sift=1
3446      FOR Block_col=St_block TO End_block
3447        Card=Block_list(Inp_no,Block_col,1)
3448        Block=((Block_list(Inp_no,Block_col,2))-1)*2+1
3449        IF Card>0 AND Block>0 THEN 
3450          PRINT TABXY((X_off+Sift),(Y_off+((Inp_no-1)*2+1)));Setup_mem$(Curr_setup_num,Card,Block)
3451          Sift=Sift+Max_out
3452        END IF
3453      NEXT Block_col
3454      Card=Block_list(Inp_no,St_block,1)
3455      Block=Block_list(Inp_no,St_block,2)
3456      IF Card>0 AND Block>0 THEN 
3457        Set_label$=Bias_label$(Card,Block)
3458        IF Disp_matrix((Inp_no-1)*2+2,2)=1 THEN 
3459          Bias_str$="*"
3460        ELSE
3461          Bias_str$=" "
3462        END IF
3463      ELSE
3464        Set_label$=""
3465        Bias_str$=" "
3466      END IF
3467      Rows=((Inp_no-1)*2+2)+Row_offset
3468      OUTPUT Dstr$ USING "#,6A,2A";Set_label$,Bias_str$
3469      PRINT TABXY(Xp+X_of,Rows);Dstr$
3470      Sift=1
3471      FOR Block_col=St_block TO End_block
3472        Card=Block_list(Inp_no,Block_col,1)
3473        Block=((Block_list(Inp_no,Block_col,2))-1)*2+2
3474        IF Card>0 AND Block>0 THEN 
3475          PRINT TABXY((X_off+Sift),(Y_off+((Inp_no-1)*2+2)));Setup_mem$(Curr_setup_num,Card,Block)
3476          Sift=Sift+Max_out
3477        END IF
3478      NEXT Block_col
3479    NEXT Inp_no
3480  SUBEND
3481  !==========================================================
3482 Setup_comm_set:SUB Setup_comm_set
3483  !----- Setup Memory Comment Set ---------------------------
3484    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3485    DIM Comm_str$[100]
3486    Max_char=20
3487    ON ERROR GOTO Comment_input
3488 Comment_input:Comm_str$=""
3489    DISP "Input comment for this setup memory. (Max "&VAL$(Max_char)&"char)";
3490    INPUT " ",Comm_str$
3491    IF LEN(Comm_str$)>Max_char THEN Comment_err
3492    Setup_comm$(Curr_setup_num)=Comm_str$
3493    CALL Set_panel_menu(0)
3494    OFF ERROR 
3495    SUBEXIT
3496 Comment_err:BEEP 
3497    GOTO Comment_input
3498  SUBEND
3499  !==========================================================
3500 Next_card_set:SUB Next_card_set
3501  !----- Next Card Select -----------------------------------
3502    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3503    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3504    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3505    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3506    Max_card_num=(SIZE(Card_info$,1)-1)
3507    IF Curr_card_num=Max_card_num THEN 
3508      Tmp_card_no=1
3509    ELSE
3510      Tmp_card_no=Curr_card_num+1
3511    END IF
3512    IF Card_info$(Tmp_card_no)<>No_card$ THEN 
3513      Curr_card_num=Tmp_card_no
3514    ELSE
3515      LOOP
3516      EXIT IF Card_info$(Tmp_card_no)<>No_card$
3517      EXIT IF Tmp_card_no=Curr_card_num
3518        IF Tmp_card_no=Max_card_num THEN 
3519          Tmp_card_no=1
3520        ELSE
3521          Tmp_card_no=Tmp_card_no+1
3522        END IF
3523      END LOOP
3524      Curr_card_num=Tmp_card_no
3525    END IF
3526    CALL Make_block_list(Curr_card_num)  !+++
3527  SUBEND
3528  !==========================================================
3529 Change_chanel: SUB Change_chanel
3530  !----- Change Chanel Mode ---------------------------------
3531    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3532    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3533    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3534    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3535    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3536    Fkey=1
3537    Key_redraw=1
3538    LOOP
3539      IF Key_redraw=1 THEN 
3540        IF Fkey=1 THEN 
3541          GOSUB Set_fkey1
3542        ELSE
3543          GOSUB Set_fkey2
3544        END IF
3545        DISP "Use softkeys to move cursor and to change status."
3546      END IF
3547    END LOOP
3548    GOTO Change_chnl_end
3549 Set_fkey1: GOSUB Softkey_clear
3550    Fkey=1
3551    Key_redraw=0
3552    ON KEY 1 LABEL " OPEN/  CLOSE ",4 GOSUB Open_close_set
3553    ON KEY 2 LABEL "  UP          ",4 GOSUB Cursor_up
3554    ON KEY 3 LABEL " LEFT         ",4 GOSUB Cursor_left
3555    ON KEY 4 LABEL " RIGHT        ",4 GOSUB Cursor_right
3556    ON KEY 5 LABEL " DOWN         ",4 GOSUB Cursor_down
3557    ON KEY 6 LABEL " MORE         ",4 GOSUB Set_fkey2
3558    ON KEY 7 LABEL " RETURN       ",4 GOTO Change_chnl_end
3559    RETURN 
3560 Set_fkey2: GOSUB Softkey_clear
3561    Fkey=2
3562    Key_redraw=0
3563    IF Disp_matrix(Cursor_pos(2,1),2)=0 THEN 
3564      ON KEY 1 LABEL " OPEN    ALL  ",4 GOSUB Card_open_all
3565      ON KEY 2 LABEL " OPEN    ROW  ",4 GOSUB Open_row_set
3566      ON KEY 3 LABEL " CLOSE   ROW  ",4 GOSUB Close_row_set
3567      ON KEY 4 LABEL "              ",4 GOSUB Key_null
3568      ON KEY 5 LABEL "              ",4 GOSUB Key_null
3569      ON KEY 6 LABEL " MORE         ",4 GOSUB Set_fkey1
3570      ON KEY 7 LABEL " RETURN       ",4 GOTO Change_chnl_end
3571      RETURN 
3572    ELSE
3573      ON KEY 1 LABEL " OPEN    ALL  ",4 GOSUB Card_open_all
3574      ON KEY 2 LABEL "DISABLE  ROW  ",4 GOSUB Disable_row_set
3575      ON KEY 3 LABEL " ENABLE  ROW  ",4 GOSUB Enable_row_set
3576      SELECT Card_info$(Curr_card_num)
3577      CASE Card_type$(1)
3578      CASE Card_type$(2)
3579        ON KEY 4 LABEL "              ",4 GOSUB Key_null
3580        ON KEY 5 LABEL "              ",4 GOSUB Key_null
3581      CASE ELSE
3582      END SELECT
3583      ON KEY 6 LABEL " MORE         ",4 GOSUB Set_fkey1
3584      ON KEY 7 LABEL " RETURN       ",4 GOTO Change_chnl_end
3585      RETURN 
3586    END IF
3587 Softkey_clear: !
3588    Key_redraw=1
3589    FOR Key_no=1 TO 8
3590      ON KEY Key_no LABEL "",4 GOSUB Key_null
3591    NEXT Key_no
3592    RETURN 
3593 Key_null: RETURN 
3594 Cursor_up: CALL Cursor_move("U")
3595    RETURN 
3596 Cursor_down: CALL Cursor_move("D")
3597    RETURN 
3598 Cursor_left: CALL Cursor_move("L")
3599    RETURN 
3600 Cursor_right: CALL Cursor_move("R")
3601    RETURN 
3602 Open_close_set: GOSUB Softkey_clear
3603    CALL Open_close
3604    CALL Set_panel_menu(0)
3605    CALL Cursor_move("C")
3606    RETURN 
3607 Card_open_all: GOSUB Softkey_clear
3608    CALL Card_all_open(Curr_setup_num,Curr_card_num,Setup_mem$(*))
3609    CALL Set_panel_menu(0)
3610    CALL Cursor_move("C")
3611    RETURN 
3612 Open_row_set: GOSUB Softkey_clear
3613    CALL Open_close_row(0)
3614    CALL Set_panel_menu(0)
3615    CALL Cursor_move("C")
3616    RETURN 
3617 Close_row_set: GOSUB Softkey_clear
3618    CALL Open_close_row(1)
3619    CALL Set_panel_menu(0)
3620    CALL Cursor_move("C")
3621    RETURN 
3622 Open_col_set: GOSUB Softkey_clear
3623    CALL Open_close_col(0)
3624    CALL Set_panel_menu(0)
3625    CALL Cursor_move("C")
3626    RETURN 
3627 Close_col_set: GOSUB Softkey_clear
3628    CALL Open_close_col(1)
3629    CALL Set_panel_menu(0)
3630    CALL Cursor_move("C")
3631    RETURN 
3632 Disable_row_set: GOSUB Softkey_clear
3633    CALL Dis_enab_row(0)
3634    CALL Set_panel_menu(0)
3635    CALL Cursor_move("C")
3636    RETURN 
3637 Enable_row_set: GOSUB Softkey_clear
3638    CALL Dis_enab_row(1)
3639    CALL Set_panel_menu(0)
3640    CALL Cursor_move("C")
3641    RETURN 
3642 Disable_col_set: GOSUB Softkey_clear
3643    CALL Dis_enab_col(0)
3644    CALL Set_panel_menu(0)
3645    CALL Cursor_move("C")
3646    RETURN 
3647 Enable_col_set: GOSUB Softkey_clear
3648    CALL Dis_enab_col(1)
3649    CALL Set_panel_menu(0)
3650    CALL Cursor_move("C")
3651    RETURN 
3652 Change_chnl_end: GCLEAR
3653    DISP "Select desired softkey."
3654  SUBEND
3655  !==========================================================
3656 Cursor_move: SUB Cursor_move(Dir$)
3657  !----- Cursor Move ----------------------------------------
3658    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
3659    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3660    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3661    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3662    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3663    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3664    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3665    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3666    Col_n=Cursor_pos(1,1)
3667    Row_n=Cursor_pos(2,1)
3668    X_pos=Xy_pos(1,1)
3669    Y_pos=Xy_pos(2,1)
3670    IF Sys_os$="IBASIC" OR Sys_os$="IBASIC_N" THEN 
3671    ELSE
3672      CALL Pos_to_inout(Row_n,Col_n,Inp_n,Out_n,Card)
3673      Curr_data$=Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]
3674      PRINT TABXY(X_pos,Y_pos);CHR$(128);Curr_data$;CHR$(128)
3675    END IF
3676    SELECT Dir$
3677    CASE "U"
3678      IF Row_n=1 THEN 
3679        Row_n=Max_row
3680      ELSE
3681        Row_n=Row_n-1
3682      END IF
3683      IF Disp_matrix(Row_n,1)<Col_n THEN 
3684        LOOP
3685          IF Row_n=1 THEN 
3686            Row_n=Max_row
3687          ELSE
3688            Row_n=Row_n-1
3689          END IF
3690        EXIT IF Disp_matrix(Row_n,1)>=Col_n
3691        END LOOP
3692      END IF
3693    CASE "D"
3694      IF Row_n=Max_row THEN 
3695        Row_n=1
3696      ELSE
3697        Row_n=Row_n+1
3698      END IF
3699      IF Disp_matrix(Row_n,1)<Col_n THEN 
3700        LOOP
3701          IF Row_n=Max_row THEN 
3702            Row_n=1
3703          ELSE
3704            Row_n=Row_n+1
3705          END IF
3706        EXIT IF Disp_matrix(Row_n,1)>=Col_n
3707        END LOOP
3708      END IF
3709    CASE "L"
3710      IF Col_n=1 THEN 
3711        Col_n=Disp_matrix(Row_n,1)
3712      ELSE
3713        Col_n=Col_n-1
3714      END IF
3715    CASE "R"
3716      IF Col_n=Disp_matrix(Row_n,1) THEN 
3717        Col_n=1
3718      ELSE
3719        Col_n=Col_n+1
3720      END IF
3721    CASE "C"
3722    CASE ELSE
3723    END SELECT
3724    IF Col_n>Max_disp_col AND Curr_page=1 THEN 
3725      Curr_page=2
3726      CALL Set_panel_menu(0)
3727    END IF
3728    IF Col_n<=Max_disp_col AND Curr_page=2 THEN 
3729      Curr_page=1
3730      CALL Set_panel_menu(0)
3731    END IF
3732    Cursor_pos(1,1)=Col_n
3733    Cursor_pos(2,1)=Row_n
3734    IF Col_n>Max_disp_col THEN 
3735      Xy_pos(1,1)=Xy_offset(1,1)+(Cursor_pos(1,1)-Max_disp_col)
3736      Xy_pos(2,1)=Xy_offset(2,1)+Cursor_pos(2,1)
3737    ELSE
3738      Xy_pos(1,1)=Xy_offset(1,1)+Cursor_pos(1,1)
3739      Xy_pos(2,1)=Xy_offset(2,1)+Cursor_pos(2,1)
3740    END IF
3741    X_pos=Xy_pos(1,1)
3742    Y_pos=Xy_pos(2,1)
3743    IF Sys_os$="IBASIC" OR Sys_os$="IBASIC_N" THEN 
3744      CALL G_cursor(1,X_gorg+((X_pos-1)*X_step),Y_gorg-((Y_pos-1)*Y_step),H_c,W_c)
3745    ELSE
3746      CALL Pos_to_inout(Row_n,Col_n,Inp_n,Out_n,Card)
3747      Next_data$=Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]
3748      PRINT TABXY(X_pos,Y_pos);CHR$(129);Next_data$;CHR$(128)
3749    END IF
3750  SUBEND
3751  !==========================================================
3752 G_cursor: SUB G_cursor(On_off,X,Y,H,W)
3753  !----- Graphic cursor display -----------------------------
3754    C_color=2
3755    GCLEAR
3756    IF On_off=1 THEN 
3757      MOVE X,Y
3758      PEN C_color
3759      IPLOT W/2.,0.
3760      IPLOT 0,H/2.
3761      IPLOT -W,0.
3762      IPLOT 0.,-H
3763      IPLOT W,0.
3764      IPLOT 0.,H/2.
3765      IPLOT -W/2,0,-2
3766    END IF
3767  SUBEND
3768  !==========================================================
3769 Pos_to_inout: SUB Pos_to_inout(Row_n,Col_n,In_no,Out_no,Card_no)
3770  !----- Cursor position to Setup memory IN/OUT/CARD number convert
3771    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3772    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3773    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3774    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3775    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3776    IF Config_mode=1 THEN 
3777      SELECT Card_info$(Curr_card_num)
3778      CASE Card_type$(2)
3779        Out_no=((Col_n-1) MOD Max_out)+1
3780        Block_col=((Col_n-1) DIV Max_out)+1
3781        Block_row=((Row_n-1) DIV 2)+1
3782        Card_no=Block_list(Block_row,Block_col,1)
3783        Block=Block_list(Block_row,Block_col,2)
3784        In_no=(Block-1)*2+2-(Row_n MOD 2)
3785      CASE ELSE
3786        In_no=Row_n
3787        Out_no=Col_n-(((Col_n-1) DIV Max_out)*Max_out)
3788        Card_no=((Col_n-1) DIV Max_out)+1
3789      END SELECT
3790    ELSE
3791      In_no=Row_n
3792      Out_no=Col_n
3793      Card_no=Curr_card_num
3794    END IF
3795  SUBEND
3796  !==========================================================
3797 Pos_to_chanel: SUB Pos_to_chanel(Row_n,Col_n,Chanel$,Bias_fg)
3798  !----- Cursor position to Chanel data convert -------------
3799    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3800    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3801    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3802    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3803    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3804    Card0=0
3805    Bias_ch_num1=10
3806    Bias_ch_num2=50
3807    IF Config_mode=1 THEN 
3808      SELECT Card_info$(Curr_card_num)
3809      CASE Card_type$(2)
3810        Out_no=Col_n
3811        Inp_no=((Row_n-1) DIV 2)+1
3812        IF (Row_n MOD 2)=0 THEN 
3813          Inp_no=Inp_no+Bias_ch_num1
3814        END IF
3815        Card_no=Card0
3816      CASE ELSE
3817        Inp_no=Row_n
3818        Out_no=Col_n
3819        Card_no=Card0
3820      END SELECT
3821    ELSE
3822      SELECT Card_info$(Curr_card_num)
3823      CASE Card_type$(2)
3824        Out_no=Col_n
3825        Inp_no=((Row_n-1) DIV 2)+1
3826        IF (Row_n MOD 2)=0 THEN 
3827          Inp_no=Inp_no+Bias_ch_num2
3828        END IF
3829        Card_no=Curr_card_num
3830      CASE ELSE
3831        Inp_no=Row_n
3832        Out_no=Col_n
3833        Card_no=Curr_card_num
3834      END SELECT
3835    END IF
3836    OUTPUT Chanel$ USING "#,1D,2Z,2Z";Card_no,Inp_no,Out_no
3837  SUBEND
3838  !==========================================================
3839 Open_close: SUB Open_close
3840  !----- Open/Close or Disable/Enable setting ---------------
3841    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
3842    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3843    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3844    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3845    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3846    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3847    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3848    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3849    INTEGER Diff_n
3850    DIM Tmp_setup_mem$(1:1,1:4,1:10)[12]
3851    Opend$="."
3852    Closd$="@"
3853    Bias_dis$="-"
3854    Row_n=Cursor_pos(2,1)
3855    Col_n=Cursor_pos(1,1)
3856    X_pos=Xy_pos(1,1)
3857    Y_pos=Xy_pos(2,1)
3858    B_stat=Bias_stat(Curr_card_num)
3859    B_port=Bias_port(Curr_card_num)
3860    CALL Pos_to_inout(Row_n,Col_n,Inp_n,Out_n,Card)
3861    Curr_data$=Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]
3862    IF Disp_matrix(Row_n,2)=1 THEN 
3863      CALL Pos_to_chanel(Row_n,Col_n,Chanel$,1)
3864      SELECT Curr_data$
3865      CASE Opend$,Closd$
3866        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Bias_dis$
3867        PRINT TABXY(X_pos,Y_pos);Bias_dis$
3868        OUTPUT @Hp5250;":ROUT:BIAS:CHAN:DIS (@"&Chanel$&")"
3869        OUTPUT @Hp5250;"*OPC?"
3870        ENTER @Hp5250;Cp
3871      CASE Bias_dis$
3872        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Opend$
3873        PRINT TABXY(X_pos,Y_pos);Opend$
3874        OUTPUT @Hp5250;":ROUT:BIAS:CHAN:ENAB (@"&Chanel$&")"
3875        OUTPUT @Hp5250;"*OPC?"
3876        ENTER @Hp5250;Cp
3877        CALL Card_data_set(Curr_card_num,Curr_setup_num)
3878      CASE ELSE
3879      END SELECT
3880    ELSE
3881      GOSUB Bias_port_check
3882      CALL Pos_to_chanel(Row_n,Col_n,Chanel$,0)
3883      SELECT Curr_data$
3884      CASE Opend$
3885        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Closd$
3886        PRINT TABXY(X_pos,Y_pos);Closd$
3887        OUTPUT @Hp5250;":ROUT:CLOS (@"&Chanel$&")"
3888        OUTPUT @Hp5250;"*OPC?"
3889        ENTER @Hp5250;Cp
3890      CASE Closd$
3891        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Opend$
3892        PRINT TABXY(X_pos,Y_pos);Opend$
3893        OUTPUT @Hp5250;":ROUT:OPEN (@"&Chanel$&")"
3894        OUTPUT @Hp5250;"*OPC?"
3895        ENTER @Hp5250;Cp
3896      CASE Bias_dis$
3897      CASE ELSE
3898      END SELECT
3899      CALL Card_data_set(Curr_card_num,Curr_setup_num)
3900    END IF
3901    SUBEXIT
3902 Bias_port_check: !
3903    SELECT Card_info$(Curr_card_num)
3904    CASE Card_type$(1)
3905      IF B_stat=1 THEN 
3906        SELECT B_port
3907        CASE 5
3908          IF Row_n=7 OR Row_n=9 THEN Set_error
3909        CASE 7
3910          IF Row_n=5 OR Row_n=9 THEN Set_error
3911        CASE 9
3912          IF Row_n=5 OR Row_n=7 THEN Set_error
3913        CASE 6
3914          IF Row_n=8 OR Row_n=10 THEN Set_error
3915        CASE 8
3916          IF Row_n=6 OR Row_n=10 THEN Set_error
3917        CASE 10
3918          IF Row_n=6 OR Row_n=8 THEN Set_error
3919        END SELECT
3920      END IF
3921    END SELECT
3922    RETURN 
3923 Set_error: BEEP 
3924    DISP "Can not set this switch"
3925    WAIT 2
3926  SUBEND
3927  !==========================================================
3928 Open_close_row: SUB Open_close_row(Open_close)
3929  !----- Row Switch OPEN/CLOSE setting ----------------------
3930    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
3931    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
3932    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
3933    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
3934    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
3935    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
3936    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
3937    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
3938    COM /Ctrldata/ Chan_list$
3939    INTEGER Diff_n
3940    Opend$="."
3941    Closd$="@"
3942    Bias_dis$="-"
3943    Chan_list$=""
3944    Row_n=Cursor_pos(2,1)
3945    Col_n=Cursor_pos(1,1)
3946    X_pos=Xy_pos(1,1)
3947    Y_pos=Xy_pos(2,1)
3948    Max_set_col=Disp_matrix(Row_n,1)
3949    B_stat=Bias_stat(Curr_card_num)
3950    B_port=Bias_port(Curr_card_num)
3951    SELECT Card_info$(Curr_card_num)
3952    CASE Card_type$(1)
3953      IF B_stat=1 THEN 
3954        SELECT B_port
3955        CASE 5
3956          IF Row_n=7 OR Row_n=9 THEN Set_error
3957        CASE 7
3958          IF Row_n=5 OR Row_n=9 THEN Set_error
3959        CASE 9
3960          IF Row_n=5 OR Row_n=7 THEN Set_error
3961        CASE 6
3962          IF Row_n=8 OR Row_n=10 THEN Set_error
3963        CASE 8
3964          IF Row_n=6 OR Row_n=10 THEN Set_error
3965        CASE 10
3966          IF Row_n=6 OR Row_n=8 THEN Set_error
3967        END SELECT
3968      END IF
3969    END SELECT
3970    IF Open_close=1 THEN 
3971      Set_data$=Closd$
3972      Out_comm$=":ROUT:CLOS (@"
3973    ELSE
3974      Set_data$=Opend$
3975      Out_comm$=":ROUT:OPEN (@"
3976    END IF
3977    FOR Set_col=1 TO Max_set_col
3978      CALL Pos_to_inout(Row_n,Set_col,Inp_n,Out_n,Card)
3979      CALL Pos_to_chanel(Row_n,Set_col,Chanel$,0)
3980      IF Curr_page=2 THEN 
3981        IF Set_col>Max_disp_col THEN 
3982          X_pos=Xy_offset(1,1)+(Set_col-Max_disp_col)
3983          Y_pos=Xy_offset(2,1)+Row_n
3984          PRINT TABXY(X_pos,Y_pos);Set_data$
3985        END IF
3986      ELSE
3987        IF Set_col<=Max_disp_col THEN 
3988          X_pos=Xy_offset(1,1)+Set_col
3989          Y_pos=Xy_offset(2,1)+Row_n
3990          PRINT TABXY(X_pos,Y_pos);Set_data$
3991        END IF
3992      END IF
3993      !
3994      Curr_data$=Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]
3995      Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Set_data$
3996      Chan_list$=Chan_list$&Chanel$&","
3997    NEXT Set_col
3998    IF LEN(Chan_list$)>0 THEN 
3999      Chan_list$=Chan_list$[1;(LEN(Chan_list$)-1)]
4000      OUTPUT @Hp5250;Out_comm$&Chan_list$&")"
4001      OUTPUT @Hp5250;"*OPC?"
4002      ENTER @Hp5250;Cp
4003    END IF
4004    CALL Card_data_set(Curr_card_num,Curr_setup_num)
4005    SUBEXIT
4006 Set_error: BEEP 
4007    DISP "Can not set this switch"
4008    WAIT 2
4009  SUBEND
4010  !==========================================================
4011 Open_close_col: SUB Open_close_col(Open_close)
4012  !---- Open/Close Setting column ---------------------------
4013    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4014    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4015    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4016    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4017    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4018    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4019    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
4020    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4021    COM /Ctrldata/ Chan_list$
4022    INTEGER Diff_n
4023    Opend$="."
4024    Closd$="@"
4025    Bias_dis$="-"
4026    Chan_list$=""
4027    Row_n=Cursor_pos(2,1)
4028    Col_n=Cursor_pos(1,1)
4029    X_pos=Xy_pos(1,1)
4030    Y_pos=Xy_pos(2,1)
4031    Max_set_row=Max_row
4032    B_stat=Bias_stat(Curr_card_num)
4033    B_port=Bias_port(Curr_card_num)
4034    IF Open_close=1 THEN 
4035      Set_data$=Closd$
4036      Out_comm$=":ROUT:CLOS (@"
4037    ELSE
4038      Set_data$=Opend$
4039      Out_comm$=":ROUT:OPEN (@"
4040    END IF
4041    FOR Set_row=1 TO Max_set_row
4042      IF Disp_matrix(Set_row,1)>=Col_n AND Disp_matrix(Set_row,2)<>1 THEN 
4043        GOSUB Bias_port_check
4044        CALL Pos_to_inout(Set_row,Col_n,Inp_n,Out_n,Card)
4045        CALL Pos_to_chanel(Set_row,Col_n,Chanel$,0)
4046        Curr_data$=Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]
4047        SELECT Card_info$(Curr_card_num)
4048        CASE Card_type$(1)
4049          SELECT Set_row
4050          CASE 7,8,9,10
4051            IF Open_close=1 THEN Skip_row
4052          END SELECT
4053        END SELECT
4054        !
4055        IF Curr_page=2 THEN 
4056          IF Col_n>Max_disp_col THEN 
4057            X_pos=Xy_offset(1,1)+(Col_n-Max_disp_col)
4058            Y_pos=Xy_offset(2,1)+Set_row
4059            PRINT TABXY(X_pos,Y_pos);Set_data$
4060          END IF
4061        ELSE
4062          IF Col_n<=Max_disp_col THEN 
4063            X_pos=Xy_offset(1,1)+Col_n
4064            Y_pos=Xy_offset(2,1)+Set_row
4065            PRINT TABXY(X_pos,Y_pos);Set_data$
4066          END IF
4067        END IF
4068        !
4069        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Set_data$
4070        Chan_list$=Chan_list$&Chanel$&","
4071 Skip_row: !
4072      END IF
4073    NEXT Set_row
4074    IF LEN(Chan_list$)>0 THEN 
4075      Chan_list$=Chan_list$[1;(LEN(Chan_list$)-1)]
4076      OUTPUT @Hp5250;Out_comm$&Chan_list$&")"
4077      OUTPUT @Hp5250;"*OPC?"
4078      ENTER @Hp5250;Cp
4079    END IF
4080    CALL Card_data_set(Curr_card_num,Curr_setup_num)
4081    SUBEXIT
4082 Bias_port_check: !
4083    SELECT Card_info$(Curr_card_num)
4084    CASE Card_type$(1)
4085      IF B_stat=1 THEN 
4086        SELECT B_port
4087        CASE 5
4088          IF Set_row=7 OR Set_row=9 THEN Set_error
4089        CASE 7
4090          IF Set_row=5 OR Set_row=9 THEN Set_error
4091        CASE 9
4092          IF Set_row=5 OR Set_row=7 THEN Set_error
4093        CASE 6
4094          IF Set_row=8 OR Set_row=10 THEN Set_error
4095        CASE 8
4096          IF Set_row=6 OR Set_row=10 THEN Set_error
4097        CASE 10
4098          IF Set_row=6 OR Set_row=8 THEN Set_error
4099        END SELECT
4100      END IF
4101    END SELECT
4102    RETURN 
4103 Set_error: GOTO Skip_row
4104  SUBEND
4105  !==========================================================
4106 Dis_enab_row: SUB Dis_enab_row(Dis_enab)
4107  !----- Bias Chanel Disable/Enable setting row -------------
4108    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4109    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4110    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4111    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
4112    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4113    COM /Ctrldata/ Chan_list$
4114    INTEGER Diff_n
4115    DIM Out_comm$[30]
4116    Opend$="."
4117    Closd$="@"
4118    Bias_dis$="-"
4119    Chan_list$=""
4120    Row_n=Cursor_pos(2,1)
4121    Col_n=Cursor_pos(1,1)
4122    X_pos=Xy_pos(1,1)
4123    Y_pos=Xy_pos(2,1)
4124    Max_set_col=Disp_matrix(Row_n,1)
4125    Bias_chanel=Disp_matrix(Row_n,2)
4126    IF Dis_enab=1 THEN 
4127      Set_data$=Opend$
4128      Out_comm$=":ROUT:BIAS:CHAN:ENAB (@"
4129    ELSE
4130      Set_data$=Bias_dis$
4131      Out_comm$=":ROUT:BIAS:CHAN:DIS (@"
4132    END IF
4133    IF Bias_chanel=1 THEN 
4134      FOR Set_col=1 TO Max_set_col
4135        CALL Pos_to_inout(Row_n,Set_col,Inp_n,Out_n,Card)
4136        CALL Pos_to_chanel(Row_n,Set_col,Chanel$,1)
4137        !
4138        IF Curr_page=2 THEN 
4139          IF Set_col>Max_disp_col THEN 
4140            X_pos=Xy_offset(1,1)+(Set_col-Max_disp_col)
4141            Y_pos=Xy_offset(2,1)+Row_n
4142            PRINT TABXY(X_pos,Y_pos);Set_data$
4143          END IF
4144        ELSE
4145          IF Set_col<=Max_disp_col THEN 
4146            X_pos=Xy_offset(1,1)+Set_col
4147            Y_pos=Xy_offset(2,1)+Row_n
4148            PRINT TABXY(X_pos,Y_pos);Set_data$
4149          END IF
4150        END IF
4151        !
4152        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Set_data$
4153        Chan_list$=Chan_list$&Chanel$&","
4154      NEXT Set_col
4155    END IF
4156    IF LEN(Chan_list$)>0 THEN 
4157      Chan_list$=Chan_list$[1;(LEN(Chan_list$)-1)]
4158      OUTPUT @Hp5250;Out_comm$&Chan_list$&")"
4159      OUTPUT @Hp5250;"*OPC?"
4160      ENTER @Hp5250;Cp
4161    END IF
4162    IF Dis_enab=1 THEN 
4163      CALL Card_data_set(Curr_card_num,Curr_setup_num)
4164    END IF
4165  SUBEND
4166  !==========================================================
4167 Dis_enab_col: SUB Dis_enab_col(Dis_enab)
4168  !----- Bias Chanel Disable/Enable setting column ----------
4169    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4170    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4171    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4172    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
4173    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4174    COM /Ctrldata/ Chan_list$
4175    INTEGER Diff_n
4176    DIM Out_comm$[30]
4177    Opend$="."
4178    Closd$="@"
4179    Bias_dis$="-"
4180    Chan_list$=""
4181    Row_n=Cursor_pos(2,1)
4182    Col_n=Cursor_pos(1,1)
4183    X_pos=Xy_pos(1,1)
4184    Y_pos=Xy_pos(2,1)
4185    Max_set_row=Max_row
4186    IF Dis_enab=1 THEN 
4187      Set_data$=Opend$
4188      Out_comm$=":ROUT:BIAS:CHAN:ENAB (@"
4189    ELSE
4190      Set_data$=Bias_dis$
4191      Out_comm$=":ROUT:BIAS:CHAN:DIS (@"
4192    END IF
4193    FOR Set_row=1 TO Max_set_row
4194      IF Disp_matrix(Set_row,1)>=Col_n AND Disp_matrix(Set_row,2)=1 THEN 
4195        CALL Pos_to_inout(Set_row,Col_n,Inp_n,Out_n,Card)
4196        CALL Pos_to_chanel(Set_row,Col_n,Chanel$,1)
4197        !
4198        IF Curr_page=2 THEN 
4199          IF Col_n>Max_disp_col THEN 
4200            X_pos=Xy_offset(1,1)+(Col_n-Max_disp_col)
4201            Y_pos=Xy_offset(2,1)+Set_row
4202            PRINT TABXY(X_pos,Y_pos);Set_data$
4203          END IF
4204        ELSE
4205          IF Col_n<=Max_disp_col THEN 
4206            X_pos=Xy_offset(1,1)+Col_n
4207            Y_pos=Xy_offset(2,1)+Set_row
4208            PRINT TABXY(X_pos,Y_pos);Set_data$
4209          END IF
4210        END IF
4211        !
4212        Setup_mem$(Curr_setup_num,Card,Inp_n)[Out_n;1]=Set_data$
4213        Chan_list$=Chan_list$&Chanel$&","
4214      END IF
4215    NEXT Set_row
4216    IF LEN(Chan_list$)>0 THEN 
4217      Chan_list$=Chan_list$[1;(LEN(Chan_list$)-1)]
4218      OUTPUT @Hp5250;Out_comm$&Chan_list$&")"
4219      OUTPUT @Hp5250;"*OPC?"
4220      ENTER @Hp5250;Cp
4221    END IF
4222    Card_data_set(Curr_card_num,Curr_setup_num)
4223  SUBEND
4224  !==========================================================
4225 Card_all_open: SUB Card_all_open(INTEGER Setup_num,REAL Card_num,Set_mem$(*))
4226  !----- Open card all switch -------------------------------
4227    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4228    INTEGER Diff_n
4229    CALL Setup_clr_card(Setup_num,Card_num,Set_mem$(*))
4230    OUTPUT @Hp5250;":ROUT:OPEN:CARD "&VAL$(Card_num)
4231    OUTPUT @Hp5250;"*OPC?"
4232    ENTER @Hp5250;Cp
4233    CALL Card_data_set(Card_num,Setup_num)
4234  SUBEND
4235  !==========================================================
4236 Card_data_set: SUB Card_data_set(Card_number,INTEGER Setup_num)
4237  !----- Card setting read ----------------------------------
4238    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4239    DIM Tmp_setup_mem$(1:1,1:4,1:10)[12]
4240    Disa$="-"
4241    Clos$="@"
4242    Open$="."
4243    Max_card_no=(SIZE(Setup_mem$,2))
4244    MAT Tmp_setup_mem$= (RPT$(".",12))
4245  ! CALL Get_dis_card(Card_number,Tmp_setup_mem$(*))
4246    CALL Get_clos_card(Card_number,Tmp_setup_mem$(*))
4247    C_type$=FNCard_data_query$(Card_number,Max_input,Max_output)
4248    IF Card_number=0 THEN 
4249      FOR Card_no=1 TO Max_card_no
4250        FOR Inp_no=1 TO Max_input
4251          FOR J=1 TO Max_output
4252            IF Setup_mem$(Setup_num,Card_no,Inp_no)[J;1]<>Disa$ THEN 
4253              Setup_mem$(Setup_num,Card_no,Inp_no)[J;1]=Tmp_setup_mem$(1,Card_no,Inp_no)[J;1]
4254            END IF
4255          NEXT J
4256        NEXT Inp_no
4257      NEXT Card_no
4258    ELSE
4259      FOR Inp_no=1 TO Max_input
4260        FOR J=1 TO Max_output
4261          IF Setup_mem$(Setup_num,Card_number,Inp_no)[J;1]<>Disa$ THEN 
4262            Setup_mem$(Setup_num,Card_number,Inp_no)[J;1]=Tmp_setup_mem$(1,Card_number,Inp_no)[J;1]
4263          END IF
4264        NEXT J
4265      NEXT Inp_no
4266    END IF
4267  SUBEND
4268  !==========================================================
4269 Get_clos_card: SUB Get_clos_card(Card_number,Tmp_setup_mem$(*))
4270  !----- Get card close switch list -------------------------
4271    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4272    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4273    COM /Ctrldata/ Chan_list$
4274    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4275    DIM Tmp_chan_list$[1800]
4276    Sep$=","
4277    Bias_ch_num1=10
4278    Bias_ch_num2=50
4279    Closed$="@"
4280    OUTPUT @Hp5250;":ROUT:CLOS:CARD? "&VAL$(Card_number)
4281    ENTER @Hp5250;Chan_list$
4282    IF LEN(Chan_list$)>0 THEN 
4283      C_type$=FNCard_data_query$(Card_number,Max_input,Max_output)
4284      Tmp_chan_list$=Chan_list$[2;(LEN(Chan_list$))-1]&Sep$
4285      Close_cnt=1
4286      LOOP
4287        Spos=POS(Tmp_chan_list$,Sep$)
4288      EXIT IF Spos=0
4289        Chan_data$=Tmp_chan_list$[1;(Spos-1)]
4290        Ch_data=VAL(Chan_data$)
4291        Card_no=INT(Ch_data DIV 10000)
4292        Input_no=INT((Ch_data-(Card_no*10000)) DIV 100)
4293        Output_no=INT(Ch_data-(Card_no*10000)-(Input_no*100))
4294        SELECT C_type$
4295        CASE Card_type$(1)
4296          IF Card_number=0 THEN 
4297            Card_no=((Output_no-1) DIV Max_output)+1
4298            In_no=Input_no
4299            Out_no=((Output_no-1) MOD Max_output)+1
4300          ELSE
4301            In_no=Input_no
4302            Out_no=Output_no
4303          END IF
4304        CASE Card_type$(2)
4305          IF Card_number=0 THEN 
4306            IF Input_no>Bias_ch_num1 THEN 
4307              In_no=(Input_no-Bias_ch_num1)
4308            ELSE
4309              In_no=Input_no
4310            END IF
4311            Block_col=((Output_no-1) DIV Max_output)+1
4312            IF In_no<=(SIZE(Block_list,1)) THEN 
4313              Card_no=Block_list(In_no,Block_col,1)
4314              Block=Block_list(In_no,Block_col,2)
4315              Out_no=((Output_no-1) MOD Max_output)+1
4316              IF Input_no>Bias_ch_num1 THEN 
4317                In_no=Block*2
4318              ELSE
4319                In_no=Block*2-1
4320              END IF
4321            END IF
4322          ELSE
4323            IF Input_no>Bias_ch_num2 THEN 
4324              In_no=(Input_no-Bias_ch_num2)*2
4325            ELSE
4326              In_no=(Input_no-1)*2+1
4327            END IF
4328            Out_no=Output_no
4329          END IF
4330        CASE ELSE
4331        END SELECT
4332        IF (In_no<=Max_input AND In_no>0) AND (Out_no<=Max_output AND Out_no>0) THEN 
4333          Tmp_setup_mem$(1,Card_no,In_no)[Out_no;1]=Closed$
4334        END IF
4335        Tmp_chan_list$=Tmp_chan_list$[Spos+1;(LEN(Tmp_chan_list$))-Spos]
4336        IF LEN(Tmp_chan_list$)>0 THEN 
4337          Close_cnt=Close_cnt+1
4338        END IF
4339      END LOOP
4340    ELSE
4341      Close_cnt=0
4342    END IF
4343  SUBEND
4344  !==========================================================
4345 Get_dis_card: SUB Get_dis_card(Card_number,Tmp_setup_mem$(*))
4346  !----- Get card disable switch list -----------------------
4347    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4348    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4349    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4350    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4351    COM /Ctrldata/ Chan_list$
4352    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4353    DIM Tmp_chan_list$[1800],Read_chan_list$[1800]
4354    Chan_list$=""
4355    Read_chan_list$=""
4356    Sep$=","
4357    Bias_ch_num1=10
4358    Bias_ch_num2=50
4359    Max_row_num=12
4360    Bias_dis$="-"
4361    C_type$=FNCard_data_query$(Card_number,Max_input,Max_output)
4362    Bias_stat_data=Bias_stat(Card_number)
4363    IF Bias_stat_data=1 THEN 
4364      SELECT C_type$
4365      CASE Card_type$(1)
4366        Bias_port_num=Bias_port(Card_number)
4367        IF Card_number=0 THEN 
4368          FOR Out_no=1 TO (Disp_matrix(Bias_port_num,1))
4369            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,Bias_port_num,Out_no,Sep$
4370            Chan_list$=Chan_list$&Chan_data$
4371          NEXT Out_no
4372        ELSE
4373          FOR Out_no=1 TO Max_output
4374            OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_number,Bias_port_num,Out_no,Sep$
4375            Chan_list$=Chan_list$&Chan_data$
4376          NEXT Out_no
4377        END IF
4378      CASE Card_type$(2)
4379        IF Card_number=0 THEN 
4380          FOR Inp=1 TO Max_row_num
4381            IF Disp_matrix(Inp,2)=1 AND Disp_matrix(Inp,1)>0 THEN 
4382              In_no=((Inp-1) DIV 2)+1+Bias_ch_num1
4383              FOR Out_no=1 TO (Disp_matrix(Inp,1))
4384                OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card0,In_no,Out_no,Sep$
4385                Chan_list$=Chan_list$&Chan_data$
4386              NEXT Out_no
4387            END IF
4388          NEXT Inp
4389        ELSE
4390          FOR Inp=1 TO Max_input
4391            IF Disp_matrix(Inp,2)=1 AND Disp_matrix(Inp,1)>0 THEN 
4392              In_no=((Inp-1) DIV 2)+1+Bias_ch_num2
4393              FOR Out_no=1 TO Max_output
4394                OUTPUT Chan_data$ USING "#,1D,2Z,2Z,A";Card_number,In_no,Out_no,Sep$
4395                Chan_list$=Chan_list$&Chan_data$
4396              NEXT Out_no
4397            END IF
4398          NEXT Inp
4399        END IF
4400      CASE ELSE
4401      END SELECT
4402    END IF
4403    IF LEN(Chan_list$)>0 THEN 
4404      Chan_list$=Chan_list$[1;(LEN(Chan_list$)-1)]
4405      OUTPUT @Hp5250;":ROUT:BIAS:CHAN:DIS? (@"&Chan_list$&")"
4406      ENTER @Hp5250;Read_chan_list$
4407    ELSE
4408      Read_chan_list$=""
4409    END IF
4410    IF LEN(Read_chan_list$)>0 THEN 
4411      C_type$=FNCard_data_query$(Card_number,Max_input,Max_output)
4412      Read_chan_list$=Read_chan_list$&Sep$
4413      Tmp_chan_list$=Chan_list$&Sep$
4414      Close_cnt=1
4415      LOOP
4416        Spos=POS(Tmp_chan_list$,Sep$)
4417        Sposr=POS(Read_chan_list$,Sep$)
4418      EXIT IF Spos=0
4419        Dis_fg=VAL(Read_chan_list$[1;(Sposr-1)])
4420        IF Dis_fg=1 THEN 
4421          Chan_data$=Tmp_chan_list$[1;(Spos-1)]
4422          Ch_data=VAL(Chan_data$)
4423          Card_no=INT(Ch_data DIV 10000)
4424          Input_no=INT((Ch_data-(Card_no*10000)) DIV 100)
4425          Output_no=INT(Ch_data-(Card_no*10000)-(Input_no*100))
4426          SELECT C_type$
4427          CASE Card_type$(1)
4428            IF Card_number=0 THEN 
4429              Card_no=((Output_no-1) DIV Max_output)+1
4430              In_no=Input_no
4431              Out_no=((Output_no-1) MOD Max_output)+1
4432            ELSE
4433              In_no=Input_no
4434              Out_no=Output_no
4435            END IF
4436          CASE Card_type$(2)
4437            IF Card_number=0 THEN 
4438              IF Input_no>Bias_ch_num1 THEN 
4439                In_no=(Input_no-Bias_ch_num1)
4440              ELSE
4441                In_no=Input_no
4442              END IF
4443              Block_col=((Output_no-1) DIV Max_output)+1
4444              IF In_no<=(SIZE(Block_list,1)) THEN 
4445                Card_no=Block_list(In_no,Block_col,1)
4446                Block=Block_list(In_no,Block_col,2)
4447                Out_no=((Output_no-1) MOD Max_output)+1
4448                IF Input_no>Bias_ch_num1 THEN 
4449                  In_no=Block*2
4450                ELSE
4451                  In_no=Block*2-1
4452                END IF
4453              END IF
4454            ELSE
4455              IF Input_no>Bias_ch_num2 THEN 
4456                In_no=(Input_no-Bias_ch_num2)*2
4457              ELSE
4458                In_no=(Input_no-1)*2+1
4459              END IF
4460              Out_no=Output_no
4461            END IF
4462          CASE ELSE
4463          END SELECT
4464          IF (In_no<=Max_input AND In_no>0) AND (Out_no<=Max_output AND Out_no>0) THEN 
4465            Tmp_setup_mem$(1,Card_no,In_no)[Out_no;1]=Bias_dis$
4466          END IF
4467        END IF
4468        Read_chan_list$=Read_chan_list$[Sposr+1;(LEN(Read_chan_list$))-Sposr]
4469        Tmp_chan_list$=Tmp_chan_list$[Spos+1;(LEN(Tmp_chan_list$))-Spos]
4470        IF LEN(Tmp_chan_list$)>0 THEN 
4471          Close_cnt=Close_cnt+1
4472        END IF
4473      END LOOP
4474    ELSE
4475      Close_cnt=0
4476    END IF
4477  SUBEND
4478  !==========================================================
4479 Save_load_data: SUB Save_load_data
4480  !----- Save/Load Data Main Routin -------------------------
4481    COM /File/ File_dev$
4482    CLEAR SCREEN
4483    DISP "Select desired softkey."
4484    Key_redraw=1
4485    LOOP
4486      IF Key_redraw=1 THEN 
4487        GOSUB Set_fkey
4488      END IF
4489    END LOOP
4490    GOTO Save_load_end
4491 Set_fkey: GOSUB Softkey_clear
4492    Key_redraw=0
4493    ON KEY 1 LABEL "CATALOG       ",2 GOSUB Catalog_disp
4494    ON KEY 3 LABEL " SAVE   FILE  ",2 GOSUB Save_file
4495    ON KEY 4 LABEL " LOAD   FILE  ",2 GOSUB Load_file
4496    ON KEY 7 LABEL " RETURN       ",2 GOTO Save_load_end
4497    RETURN 
4498 Softkey_clear: !
4499    Key_redraw=1
4500    FOR Key_no=1 TO 8
4501      ON KEY Key_no LABEL "",2 GOSUB Key_null
4502    NEXT Key_no
4503    RETURN 
4504 Key_null: RETURN 
4505 Catalog_disp: GOSUB Softkey_clear
4506    CALL Cat_file(File_dev$)
4507    RETURN 
4508 Save_file: GOSUB Softkey_clear
4509    CALL Save_file
4510    RETURN 
4511 Load_file: GOSUB Softkey_clear
4512    CALL Load_file
4513    RETURN 
4514 Save_load_end: CLEAR SCREEN
4515    CALL Main_menu
4516  SUBEND
4517  !==========================================================
4518 Save_file: SUB Save_file
4519  !----- Save File ------------------------------------------
4520    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4521    COM /Label/ Input_label$(*),Bias_label$(*)
4522    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4523    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4524    COM /File/ File_dev$
4525    COM /Revision/ Rev_id$
4526    DIM File_name$[20]
4527    INTEGER Setup_num,Slot_num,Inp_num,Out_num,Rev_num
4528    File_name$=FNInput_file_name$("Input Save file name")
4529    IF File_name$="" THEN Save_file_end
4530 Save_start: DISP "Saving file ...[";File_name$;"]"
4531    ON ERROR GOTO Save_error
4532    Rpb=256
4533    GOSUB Rec_calc
4534    CREATE File_name$&File_dev$,(Rec*Rpb)
4535    ASSIGN @F TO File_name$&File_dev$
4536    OUTPUT @F;Rev_id$,Setup_num,Slot_num,Inp_num,Out_num
4537    OUTPUT @F;Card_info$(*),Config_mode,Card_conf$(*),Bias_stat(*),Bias_port(*)
4538    OUTPUT @F;Input_label$(*),Bias_label$(*),Setup_comm$(*),Setup_mem$(*)
4539    DISP "File save completed"
4540    WAIT 1
4541    DISP "Select desired softkey."
4542    GOTO Save_file_end
4543 Rec_calc: Rev_num=7
4544    Card_num=SIZE(Card_info$,1)
4545    Setup_num=SIZE(Setup_mem$,1)
4546    Slot_num=SIZE(Setup_mem$,2)
4547    Inp_num=SIZE(Setup_mem$,3)
4548    Out_num=12
4549    Inp_label=SIZE(Input_label$,1)
4550    Bias_num=SIZE(Bias_label$,2)
4551    Rev_size=Rev_num*(Rev_num+1+4)
4552    Setup_size=Setup_num*2
4553    Slot_size=Slot_num*2
4554    Inp_size=Inp_num*2
4555    Out_size=Out_num*2
4556    C_i_b=Card_num*(6+4)
4557    I_l_b=Inp_label*(5+4)
4558    C_c_b=Card_num*(6+4)
4559    B_l_b=(Card_num-1)*Bias_num*(5+4)
4560    S_c_b=Setup_num*(20+4)
4561    C_m_b=2
4562    B_s_b=Card_num*2
4563    B_p_b=Card_num*2
4564    S_m_b=Setup_num*(Card_num-1)*Inp_num*(Out_num+1+4)
4565    Tbyte=Rev_size+Setup_size+Slot_size+Inp_size+Out_size+C_i_b+I_l_b+B_l_b+S_c_b+C_m_b+B_s_b+B_p_b+S_m_b+C_c_b
4566    Rec=(Tbyte DIV Rpb)+1
4567    RETURN 
4568 Over_write: DISP "File [";File_name$;"] exists. Overwrite OK?"
4569    FOR Key_no=1 TO 8
4570      ON KEY Key_no LABEL "",3 GOSUB Key_null
4571    NEXT Key_no
4572    ON KEY 1 LABEL " OVER   WRITE ",3 GOTO Write_file
4573    ON KEY 7 LABEL " CANCEL       ",3 GOTO Save_file_end
4574    LOOP
4575    END LOOP
4576    GOTO Save_file_end
4577 Key_null: RETURN 
4578 Write_file: DISP "PURGE "&File_name$&File_dev$
4579    PURGE File_name$&File_dev$
4580    GOTO Save_start
4581 Save_error: !
4582    IF ERRN=54 THEN 
4583      GOTO Over_write
4584    ELSE
4585      BEEP 
4586      DISP "*** "&ERRM$
4587    END IF
4588 Save_file_end: OFF ERROR 
4589    ASSIGN @F TO *
4590    DISP "Select desired softkey."
4591  SUBEND
4592  !==========================================================
4593 Cat_file: SUB Cat_file(File_dev$)
4594  !----- File catalog display -------------------------------
4595    ON ERROR GOTO Cat_error
4596    CLEAR SCREEN
4597    IF LEN(TRIM$(File_dev$))=0 THEN 
4598      CAT 
4599    ELSE
4600      CAT File_dev$
4601    END IF
4602    OFF ERROR 
4603    GOTO Cat_end
4604 Cat_error: BEEP 
4605    DISP "*** "&ERRM$
4606    WAIT 2
4607 Cat_end: DISP "Select desired softkey."
4608  SUBEND
4609  !==========================================================
4610 Input_file_name: DEF FNInput_file_name$(Message$)
4611  !----- Input file name ------------------------------------
4612    DIM File_name$[20]
4613    Max_name_len=8
4614 Input_name: ON ERROR GOTO Input_error
4615    DISP Message$;
4616    INPUT " ",File_name$
4617    IF File_name$<>"" THEN 
4618      IF LEN(File_name$)>Max_name_len THEN Input_error
4619    END IF
4620    OFF ERROR 
4621    RETURN File_name$
4622 Input_error: BEEP 
4623    DISP "File name is too long."
4624    WAIT 1
4625    File_name$=""
4626    GOTO Input_name
4627  FNEND
4628  !==========================================================
4629 Load_file: SUB Load_file
4630  !----- Load File ------------------------------------------
4631    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4632    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4633    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4634    COM /Label/ Input_label$(*),Bias_label$(*)
4635    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4636    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4637    COM /Set_panel/ Curr_card_num,Cursor_pos(*),Xy_pos(*),Curr_page,Max_col,Max_row,Xy_offset(*),Max_disp_col
4638    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4639    COM /File/ File_dev$
4640    COM /Revision/ Rev_id$
4641    DIM File_name$[20]
4642    DIM Input_label_tmp$(1:10)[5],Bias_label_tmp$(1:4,1:3)[5]
4643    DIM Comp_data(0:4)
4644    INTEGER Config_mode_tmp,Bias_stat_tmp(0:4),Bias_port_tmp(0:4)
4645    INTEGER Setupn,Slotn,Inpn,Outn,Setup_comm_len,Card_info_len
4646    Max_card_no=(SIZE(Card_info$,1)-1)
4647    Max_setup_num=SIZE(Setup_mem$,1)
4648    Setup_comm_len=20
4649    Card_info_len=6
4650    File_name$=FNInput_file_name$("Input Load file name")
4651    IF File_name$="" THEN Load_file_end
4652    DISP "Loading file ...[";File_name$;"]"
4653    ON ERROR GOTO Load_error
4654    ASSIGN @F TO File_name$&File_dev$
4655    ENTER @F;Rev_id$,Setupn,Slotn,Inpn,Outn
4656    ALLOCATE Setup_mem_tmp$(1:Slotn,1:Inpn)[Outn]
4657    ALLOCATE Setup_comm_tmp$(1:Setupn)[Setup_comm_len]
4658    ALLOCATE Card_info_tmp$(0:Slotn)[Card_info_len],Card_conf_tmp$(0:Slotn)[Card_info_len]
4659    ENTER @F;Card_info_tmp$(*),Config_mode_tmp
4660    IF Config_mode_tmp=1 THEN 
4661      IF Card_info_tmp$(0)="" OR Card_info$(0)="" OR Card_info_tmp$(0)<>Card_info$(0) THEN No_set_error
4662    END IF
4663    ENTER @F;Card_conf_tmp$(*),Bias_stat_tmp(*),Bias_port_tmp(*)
4664    ENTER @F;Input_label_tmp$(*),Bias_label_tmp$(*),Setup_comm_tmp$(*)
4665    FOR Setup_num=1 TO Max_setup_num
4666      ENTER @F;Setup_mem_tmp$(*)
4667      IF Config_mode_tmp=0 THEN 
4668        FOR Card_no=1 TO Max_card_no
4669          Sys_card$=FNCard_data_query$(Card_no,Max_in,Max_out)
4670          Data_card$=Card_info_tmp$(Card_no)
4671          IF Sys_card$<>"" THEN 
4672            IF Sys_card$=Data_card$ THEN 
4673              Bias_stat(Card_no)=Bias_stat_tmp(Card_no)
4674              Bias_port(Card_no)=Bias_port_tmp(Card_no)
4675              IF Card_no=1 THEN 
4676                Bias_stat(0)=Bias_stat_tmp(0)
4677                Bias_port(0)=Bias_port_tmp(0)
4678              END IF
4679              IF Max_in<=Inpn AND Max_out<=Outn THEN 
4680                FOR I=1 TO Max_in
4681                  Setup_mem$(Setup_num,Card_no,I)=Setup_mem_tmp$(Card_no,I)[1;Max_out]
4682                NEXT I
4683              ELSE
4684                BEEP 
4685                DISP "Matrix type (";Inpn;"x";Outn;") is not same (";Max_in;"x";Max_out;")"
4686                WAIT 1
4687                GOTO Load_file_end
4688              END IF
4689            ELSE
4690              Bias_stat(Card_no)=0
4691              FOR I=1 TO Max_in
4692                IF Setup_mem$(Setup_num,Card_no,I)<>"-" THEN 
4693                  Setup_mem$(Setup_num,Card_no,I)=RPT$(".",Max_out)
4694                END IF
4695              NEXT I
4696            END IF
4697          END IF
4698        NEXT Card_no
4699      ELSE
4700        Sys_card0$=FNCard_data_query$(0,Max_in,Max_out)
4701        Card_no=1
4702        LOOP
4703          Sys_card$=Card_info$(Card_no)
4704          Data_card$=Card_info_tmp$(Card_no)
4705        EXIT IF Sys_card$<>Sys_card0$
4706          IF Sys_card$=Data_card$ THEN 
4707            Bias_stat(Card_no)=Bias_stat_tmp(Card_no)
4708            Bias_port(Card_no)=Bias_port_tmp(Card_no)
4709            IF Card_no=1 THEN 
4710              Bias_stat(0)=Bias_stat_tmp(0)
4711              Bias_port(0)=Bias_port_tmp(0)
4712            END IF
4713            IF Max_in<=Inpn AND Max_out<=Outn THEN 
4714              FOR I=1 TO Max_in
4715                Setup_mem$(Setup_num,Card_no,I)=Setup_mem_tmp$(Card_no,I)[1;Max_out]
4716              NEXT I
4717            ELSE
4718              BEEP 
4719              DISP "Matrix type (";Inpn;"x";Outn;") is not same (";Max_in;"x";Max_out;")"
4720              WAIT 1
4721              GOTO Load_file_end
4722            END IF
4723          ELSE
4724            Bias_stat(Card_no)=0
4725            FOR I=1 TO Max_in
4726              IF Setup_mem$(Setup_num,Card_no,I)<>"-" THEN 
4727                Setup_mem$(Setup_num,Card_no,I)=RPT$(".",Max_out)
4728              END IF
4729            NEXT I
4730          END IF
4731          Card_no=Card_no+1
4732        EXIT IF Card_no>Max_card_no
4733        END LOOP
4734      END IF
4735      Setup_comm$(Setup_num)=Setup_comm_tmp$(Setup_num)
4736    NEXT Setup_num
4737    FOR Card_no=1 TO Max_card_no
4738      FOR I=1 TO (SIZE(Bias_label$,2))
4739        Bias_label$(Card_no,I)=Bias_label_tmp$(Card_no,I)
4740      NEXT I
4741    NEXT Card_no
4742    FOR I=1 TO (SIZE(Input_label$,1))
4743      Input_label$(I)=Input_label_tmp$(I)
4744    NEXT I
4745    Config_mode=Config_mode_tmp
4746    Curr_setup_num=1
4747    DISP "File load completed"
4748    WAIT 1
4749    IF Config_mode=1 THEN CALL Make_block_list(0)  !+++
4750    DISP "Setting E5250A H/W ..."
4751    CALL Hp5250_set_ini
4752    CALL Hp5250_setup
4753    DISP "Select desired softkey."
4754    WAIT 1
4755    GOTO Load_file_end
4756 No_set_error: BEEP 
4757    PRINT "Cannot configure for AUTO. Normal mode used."
4758    DISP "Select desired softkey."
4759    GOTO Load_file_end
4760 Load_error: BEEP 
4761    DISP "*** "&ERRM$
4762 Load_file_end: OFF ERROR 
4763    ASSIGN @F TO *
4764    DISP "Select desired softkey."
4765  SUBEND
4766  !==========================================================
4767 Make_block_list: SUB Make_block_list(Card_num)
4768  !-----
4769    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4770    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4771    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4772    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4773    COM /Menu_disp/ X_org,Y_org,X_gorg,Y_gorg,X_step,Y_step,W_c,H_c,Disp_matrix(*)
4774    COM /Set_panel2/ Max_out,Max_in,Block_list(*)
4775    Max_block=3
4776    Max_slot_no=(SIZE(Card_info$,1)-1)
4777    C_type$=FNCard_data_query$(Card_num,Max_in,Max_out)
4778    SELECT C_type$
4779    CASE Card_type$(1)
4780      IF Card_num=0 THEN 
4781        Max_card_no=FNCont_same_card(Card_type$(1))
4782        Max_inp_no=Max_in
4783        Max_out_no=Max_card_no*Max_out
4784      ELSE
4785        Max_inp_no=Max_in
4786        Max_out_no=Max_out
4787      END IF
4788      Bias_stat_num=Bias_stat(Card_num)
4789      Bias_port_num=Bias_port(Card_num)
4790      FOR Inp_no=1 TO Max_inp_no
4791        IF Inp_no=Bias_port_num AND Bias_stat_num=1 THEN 
4792          Disp_matrix(Inp_no,1)=Max_out_no
4793          Disp_matrix(Inp_no,2)=1
4794        ELSE
4795          Disp_matrix(Inp_no,1)=Max_out_no
4796          Disp_matrix(Inp_no,2)=0
4797        END IF
4798      NEXT Inp_no
4799    CASE Card_type$(2)
4800      IF Card_num=0 THEN 
4801        Max_row=Max_in*2
4802        Max_card_no=FNCont_same_card(Card_type$(2))
4803        Bias_stat_num=Bias_stat(Card_num)
4804        FOR Card=1 TO Max_card_no
4805          FOR I=1 TO Max_block
4806            In_port_num(Card,I)=VAL(Card_conf$(Card)[((I-1)*2+1);1])
4807          NEXT I
4808        NEXT Card
4809        MAT Block_list= (0)
4810        Max_col=0
4811        FOR Inp=1 TO Max_in
4812          Block_col=1
4813          FOR Card=1 TO Max_card_no
4814            FOR Block=1 TO Max_block
4815              IF Inp=In_port_num(Card,Block) THEN 
4816                Block_list(Inp,Block_col,1)=Card
4817                Block_list(Inp,Block_col,2)=Block
4818                Block_col=Block_col+1
4819              END IF
4820            NEXT Block
4821          NEXT Card
4822          Tmp_max_col=(Block_col-1)*Max_out
4823          IF Tmp_max_col>Max_col THEN Max_col=Tmp_max_col
4824          Disp_matrix((Inp-1)*2+1,1)=Tmp_max_col
4825          Disp_matrix((Inp-1)*2+2,1)=Tmp_max_col
4826          Disp_matrix((Inp-1)*2+1,2)=0
4827          IF Bias_stat_num=1 THEN 
4828            Disp_matrix((Inp-1)*2+2,2)=1
4829          ELSE
4830            Disp_matrix((Inp-1)*2+2,2)=0
4831          END IF
4832        NEXT Inp
4833      ELSE
4834        Bias_stat_num=Bias_stat(Card_num)
4835        FOR Inp_no=1 TO Max_in
4836          IF (Inp_no MOD 2)=0 THEN 
4837            IF Bias_stat_num=1 THEN 
4838              Disp_matrix(Inp_no,1)=Max_out
4839              Disp_matrix(Inp_no,2)=1
4840            ELSE
4841              Disp_matrix(Inp_no,1)=Max_out
4842              Disp_matrix(Inp_no,2)=0
4843            END IF
4844          ELSE
4845            Disp_matrix(Inp_no,1)=Max_out
4846            Disp_matrix(Inp_no,2)=0
4847          END IF
4848        NEXT Inp_no
4849      END IF
4850    END SELECT
4851  SUBEND
4852  !==========================================================
4853 Hp5250_set_ini: SUB Hp5250_set_ini
4854  !-----
4855    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4856    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4857    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4858    COM /Setup/ INTEGER Config_mode,Bias_stat(*),Bias_port(*)
4859    COM /Setup_mem/ Setup_mem$(*),Setup_comm$(*),INTEGER Curr_setup_num
4860    IF Config_mode=0 THEN 
4861      Confm$="NCON"
4862    ELSE
4863      Confm$="ACON"
4864    END IF
4865    OUTPUT @Hp5250;":ROUT:FUNC "&Confm$
4866    IF Config_mode=0 THEN 
4867      FOR Card_no=1 TO (SIZE(Bias_stat,1)-1)
4868        IF Card_info$(Card_no)<>No_card$ THEN 
4869          OUTPUT @Hp5250;":ROUT:BIAS:STAT "&VAL$(Card_no)&","&VAL$(Bias_stat(Card_no))
4870          SELECT Card_info$(Card_no)
4871          CASE Card_type$(1)
4872            OUTPUT @Hp5250;":ROUT:BIAS:PORT "&VAL$(Card_no)&","&VAL$(Bias_port(Card_no))
4873          CASE ELSE
4874          END SELECT
4875        END IF
4876      NEXT Card_no
4877    ELSE
4878      Card_no=0
4879      OUTPUT @Hp5250;":ROUT:BIAS:STAT "&VAL$(Card_no)&","&VAL$(Bias_stat(Card_no))
4880      SELECT Card_info$(Card_no)
4881      CASE Card_type$(1)
4882        OUTPUT @Hp5250;":ROUT:BIAS:PORT "&VAL$(Card_no)&","&VAL$(Bias_port(Card_no))
4883      CASE ELSE
4884      END SELECT
4885    END IF
4886    OUTPUT @Hp5250;"*OPC?"
4887    ENTER @Hp5250;Cp
4888    Err_stat=FNAll_open_set
4889  SUBEND
4890  !==========================================================
4891 All_enabl_set: DEF FNAll_enabl_set
4892  !-----
4893    COM /Ctrldev/ Sys_os$,@Hp5250,INTEGER Hpib_sc,Hpib_addr,Addr_5250
4894    COM /Card_type/ No_card$,Card_type$(*),Sys_id$,INTEGER Max_card_type
4895    COM /Card/ Card_desc$(*),Card_conf$(*),Card_info$(*)
4896    INTEGER Err_n
4897    DIM Err_str$[80]
4898    OUTPUT @Hp5250;":ROUT:BIAS:CHAN:ENAB:CARD ALL"
4899    OUTPUT @Hp5250;"*OPC?"
4900    ENTER @Hp5250;Cp
4901    OUTPUT @Hp5250;":SYST:ERR?"
4902    ENTER @Hp5250;Err_n,Err_str$
4903    RETURN Err_n
4904  FNEND
4905  !==========================================================
