ON ERROR REPORT:END

FOR podule% = 0 TO 9
  podule_id% = FNget_podule_id(podule%)
  PRINT "Podule slot ";podule%;" = ";podule_id%
NEXT

END

 DEFFNget_podule_id(podule_slot%)
   REM This function will get the podule id code for the given podule slot.
   REM If there is no podule in the slot then the error number &0502 will be
   REM returned by the system call, the function checks for this error and
   REM if present will make the function return the podule id of -1,
   REM otherwise the function will return the podule id code. If the podule
   REM id code is 0 then the podule has an extended id code, the function
   REM will use the read header system call.
   LOCAL value%
   LOCAL flag%
   LOCAL id_code%
   LOCAL swi_error%
   LOCAL podule_buff%
   LOCAL id_mask%
   DIM podule_buff% 16
   id_mask% = &78
   SYS "XPodule_ReadID",,,,podule_slot% TO value%; flag%
   IF (flag% AND &01) = &01 THEN
       IF value%!0=&0502 THEN
           id_code% = -1
           swi_error% = TRUE
         ENDIF
     ELSE
       swi_error% = FALSE
     ENDIF
   IF (swi_error% = FALSE) AND ((value% AND id_mask%) = 0) THEN
       SYS "Podule_ReadHeader",,,podule_buff%,podule_slot% TO value%
       id_code% = podule_buff%?3 OR (podule_buff%?4<<8)
     ELSE
       id_code% = value% AND id_mask%
     ENDIF
 = id_code%
