; PROCOMM PLUS Version 2.0 Converted ASPECT Script File: AFSMNU.ASP
; Original script file renamed to: AFSMNU.AS1

integer aux_int_1
;
; menue fuer afs-download
;
proc main
        clear
;
        init    n1 0      ; 0 = select color screen
                          ; 1 = select lcd screen
        if zero n1
          init    n9 0      ;color for shadow box
          init    n8 112    ;color for box and normal video
          init    n7 78     ;color for item select
          init    n6 94     ;color for file's
        else
          init    n9 119    ;lcd-color for shadow box
          init    n8 7      ;lcd-color for box and normal video
          init    n7 112    ;lcd-color for item select
          init    n6 16     ;lcd-color for file's
        endif
        ;
        if not eq n0 55
        assign  s0 "STOP"
        assign  s1 "STOP"
        assign  s2 "STOP"
        assign  s3 "STOP"
        assign  s4 " "      ;option "D"
        assign  s9 " "      ;option "O"
        endif
;***         fopeno "AFSLOAD.LOG" text
        fopen 1 "AFSLOAD.LOG" "wt"
;***         fcloseo
        fclose 1
        log open "AFSLOAD.LOG"
        ;
afsbegin1:
        clear
        box 3 12 21 72 n9
        box 2 10 20 70 n8
        atsay 2 20 n7 "   A F S  --  DOWNLOADING  MENUE         "
        atsay 20 25 n7 "     PRESS KEY TO SELECT :     "
        atsay 4 14 n7 " 0- "
        atsay 5 14 n7 " 1- "
        atsay 6 14 n7 " 2- "
        atsay 7 14 n7 " 3- "
        atsay 8 14 n7 " D- "
        atsay 10 14 n7 " L- "
        ;
        atsay 13 14 n7 " O- "
        atsay 15 14 n7 " G- "
        ;
        atsay 17 14 n7 " S- "
        atsay 18 14 n7 " E- "
        ;
        atsay 4 20 n8 " MODUL-0 ..."
        atsay 5 20 n8 " MODUL-1 ..."
        atsay 6 20 n8 " MODUL-2 ..."
        atsay 7 20 n8 " MODUL-3 ..."
        atsay 8 20 n8 " DIRECTORY ..."
        atsay 10 20 n8 " LOAD FILES TO AFS-MODUL'S ..."
        ;
        atsay 13 20 n8 " OPERATING SYSTEM ..."
        atsay 15 20 n8 " START LOADING 'OS'"
        ;
        atsay 17 20 n8 " SAVE OPTIONS ..."
        atsay 18 20 n8 " EXIT ..."
        atsay 4 32 n6 "                  "
        atsay 5 32 n6 "                  "
        atsay 6 32 n6 "                  "
        atsay 7 32 n6 "                  "
        atsay 9 21 n6 "                                            "
        atsay 14 21 n6 "                                            "
        atsay 4 32 n6 s0
        atsay 5 32 n6 s1
        atsay 6 32 n6 s2
        atsay 7 32 n6 s3
        atsay 9 21 n6 s4
        ;
        atsay 14 21 n6 s9
        ;
afsbegin:
;
        locate  20 52
        atget 20 52 n7 2 s8
        switch  s8
         case    "0"
          atsay 4 51 n8 "              "
          atget 4 32 n6 18 s0
          strcat s0 " "
          goto afsbegin
         endcase
         case    "1"
          atsay 5 51 n8 "              "
          atget 5 32 n6 18 s1
          strcat s1 " "
          goto afsbegin
         endcase
         case    "2"
          atsay 6 51 n8 "              "
          atget 6 32 n6 18 s2
          strcat s2 " "
          goto afsbegin
          endcase
         case    "3"
          atsay 7 51 n8 "              "
          atget 7 32 n6 18 s3
          strcat s3 " "
          goto afsbegin
         endcase
         case    "d"
          atsay 4 51 n8 "              "
          atsay 5 51 n8 "              "
          atsay 6 51 n8 "              "
          atsay 7 51 n8 "              "
          atget 9 21 n6 44 s4
          goto afsbegin
         endcase
         case "o"
          atsay 13 51 n8 "              "
          atget 14 21 n6 44 s9
          goto afsbegin
         endcase
         case "g"
          gosub loados
          if not zero n5
            goto afsbegin
          else
            goto afsbegin1
          endif
         endcase
         case    "s"
          gosub saveoption
          goto afsbegin1
         endcase
         case    "l"
          gosub loadafs
          if not zero n5
            goto afsbegin
          else
            goto afsbegin1
          endif
         endcase
         case    "e"
          clear
          log close
          exit
         endcase
         default
          goto afsbegin
         endcase
        endswitch
        goto afsbegin
        ;
        exit
        ;
;
;**********************************************************
;
endproc

;*** loados:
proc loados
        init n5 0
        isfile s9
        if not success
        atsay 13 51 n7 "FILE NOT FOUND"
        init n5 100
        return
        endif
        ;
        clear
        box 11 5 15 78 n9
        box 10 3 14 76 n7
        atsay 12 5 n7 "  SET DS5000 TO PROGRAMM-MODE AND PRESS ANY KEY TO CONTINUE !  "
        kflush
        locate 2 1
;***         keyget s8
        keyget aux_int_1
        key2ascii aux_int_1 s8
        clear
        pause 1
loopos:
        transmit "^M"
        waitfor ">" 1
        if waitfor
        transmit "r^M"
        transmit "wf8^M"
        transmit "r^M"
        transmit "l^M"
        sendfile ascii s9
        else
        goto loopos
        endif
        ;
        clear
        box 11 5 15 78 n9
        box 10 3 14 76 n7
        atsay 12 10 n7 "       SET DS5000 to RUN-MODE !                 "
        locate 16 1
        waitfor ".." 30
        if waitfor
        transmit "^M"
        clear
        return
        endif
        alarm 2
        clear
        box 17 5 22 78 n9
        box 16 3 21 76 n7
        atsay 19 5 n7 "TIMEOUT! SET AFS TO 'CF-MON' AND START PROGRAMM AGAIN."
        locate 23 1
        exit
        ;
;************************************************
;
endproc

;*** loadafs:
proc loadafs
        init n5 0
        find s4 " "
        if not found
          strcpy s5 s4
          strcat s5 s0    ;path\filename for modul 0
        else
          strcpy s5 s0
        endif
        if not found
          strcpy s6 s4
          strcat s6 s1    ;path\filename for modul 1
        else
          strcpy s6 s1
        endif
        if not found
          strcpy s7 s4
          strcat s7 s2    ;path\filename for modul 2
        else
          strcpy s7 s2
        endif
        if not found
          strcpy s8 s4
          strcat s8 s3    ;path\filename for modul 3
        else
          strcpy s8 s3
        endif
        ;
        ; check file exist's
        ;
        find s5 "stop"
        if not found
          find s5 "skip"
          if not found
            isfile s5
            if not success
              atsay 4 51 n7 "FILE NOT FOUND"
              inc     n5
            endif
          endif
        endif
        ;
        find s6 "stop"
        if not found
          find s6 "skip"
          if not found
            isfile s6
            if not success
              atsay 5 51 n7 "FILE NOT FOUND"
              inc     n5
            endif
          endif
        endif
        ;
        find s7 "stop"
        if not found
          find s7 "skip"
          if not found
            isfile s7
            if not success
              atsay 6 51 n7 "FILE NOT FOUND"
              inc     n5
            endif
          endif
        endif
        ;
        find s8 "stop"
        if not found
          find s8 "skip"
          if not found
            isfile s8
            if not success
              atsay 7 51 n7 "FILE NOT FOUND"
              inc     n5
            endif
          endif
        endif
        ;
        if not zero n5
        return
        endif
        ;
clear
;
;  loading all files
        find s5 "skip"
        if not found
          message "^M^J  DOWNLOADING  MODUL 0  -->"
          find s5 "stop"
          if found
            message "  RESET/STOP MODUL 0 !"
            TRANSMIT "d0^M"
            pause 1
            transmit "end^M"
            transmit "end^M"
          else
            message s5
            TRANSMIT "d0^M"
            PAUSE 1
            sendfile ascii s5
            TRANSMIT "^M"
            PAUSE 1
            sendfile ascii s5
            TRANSMIT "^M"
            waitfor "CF>" 30
          endif
        else
          message "^M^L  MODUL 0 --> NOTHING LOADED !"
        endif
        ;
;
;**************************************
;
        find s6 "skip"
        if not found
          message "^M^J  DOWNLOADING  MODUL 1  -->"
          find s6 "stop"
          if found
            message "  RESET/STOP MODUL 1 !"
            TRANSMIT "d1^M"
            pause 1
            transmit "end^M"
            transmit "end^M"
          else
            message s6
            TRANSMIT "d1^M"
            pause 1
            sendfile ascii s6
            TRANSMIT "^M"
            PAUSE 1
            sendfile ascii s6
            TRANSMIT "^M"
            waitfor "CF>" 30
          endif
        else
          message "^M^L  MODUL 1 --> NOTHING LOADED !"
        endif
        ;
;
;**************************************
;
        find s7 "skip"
        if not found
          message "^M^J  DOWNLOADING  MODUL 2  -->"
          find s7 "stop"
          if found
            message "  RESET/STOP MODUL 2 !"
            TRANSMIT "d2^M"
            pause 1
            transmit "end^M"
            transmit "end^M"
          else
            message s7
            TRANSMIT "d2^M"
            pause 1
            sendfile ascii s7
            TRANSMIT "^M"
            PAUSE 1
            sendfile ascii s7
            TRANSMIT "^M"
            waitfor "CF>" 30
          endif
        else
          message "^M^L  MODUL 2 --> NOTHING LOADED !"
        endif
        ;
;
;**************************************
;
        find s8 "skip"
        if not found
          message "^M^J  DOWNLOADING  MODUL 3  -->"
          find s8 "stop"
          if found
            message "  RESET/STOP MODUL 3 !"
            TRANSMIT "d3^M"
            pause 1
            transmit "end^M"
            transmit "end^M"
          else
            message s8
            TRANSMIT "d3^M"
            pause 1
            sendfile ascii s8
            TRANSMIT "^M"
            PAUSE 1
            sendfile ascii s8
            TRANSMIT "^M"
            waitfor "CF>" 30
          endif
        else
          message "^M^L  MODUL 3 --> NOTHING LOADED !"
        endif
        return
        ;
;
;
;************************************************
;
endproc

;*** saveoption:
proc saveoption
        box 11 15 17 65 n9
        box 10 13 16 63 n7
        atsay 12 21 n7 "ENTER FILENAME : "
        atget 12 37 n6 20 s5
        isfile s5
        if      success
        atsay   14 21 n7 "FILE EXSITS REPLACE? Y/N :"
        atget   14 47 n6 3 s6
        switch  s6
          case  "n"
            clear
            return
          endcase
          case "y"
            clear
          endcase
          default
            clear
            return
          endcase
        endswitch
        endif
;***         fopeno s5 text
        fopen 1 s5 "wt"
        fputs 1 "proc main"
        fputc 1 10
;***         fputs "init n0 55"
        fputs 1 "init n0 55"
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s0 `"" 11
        fwrite 1 "assign s0 `"" 11
;***         fputs s0
        fputs 1 s0
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s1 `"" 11
        fwrite 1 "assign s1 `"" 11
;***         fputs s1
        fputs 1 s1
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s2 `"" 11
        fwrite 1 "assign s2 `"" 11
;***         fputs s2
        fputs 1 s2
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s3 `"" 11
        fwrite 1 "assign s3 `"" 11
;***         fputs s3
        fputs 1 s3
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s4 `"" 11
        fwrite 1 "assign s4 `"" 11
;***         fputs s4
        fputs 1 s4
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fwrite "assign s9 `"" 11
        fwrite 1 "assign s9 `"" 11
;***         fputs s9
        fputs 1 s9
;***         fputc "`""
        fputc 1 34
;***         fputc "^J"
        fputc 1 10
;***         fputs "execute c:\afsapl\afsmnu"
        fputs 1 "execute `"\afsapl\afsmnu`""
        fputc 1 10
        fputs 1 "endproc"
;***         fputc "^J"
        fputc 1 10
;***         fcloseo
        fclose 1
        string  d1
        d1="aspcomp "
        strcat d1 s5
        dos d1 WAIT
        return
;
; ende afs-downloading menue
;
endproc
