10月 09, 2015

asp.net FTP上傳檔案和獲取修改時間

        Dim wc As New WebClient()
        wc.Credentials = New NetworkCredential("hello", "***")
        wc.UploadFile("ftp://127.0.0.1/sort.zip", MapPath("sort.zip"))

        Dim ftp As FtpWebRequest = CType(FtpWebRequest.Create("ftp://127.0.0.1/sort.zip"), FtpWebRequest)
        ftp.Credentials = New NetworkCredential("hello", "***")
        ftp.Method = WebRequestMethods.Ftp.GetDateTimestamp
        Dim uu As FtpWebResponse = ftp.GetResponse
        Label1.Text = uu.LastModified

9月 30, 2015

COBOL 寫檔


        COPY 'UTI\UNY.FC'.

        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\UNIT.FD'.
        COPY 'UTI\UNY.FD'.

        WORKING-STORAGE SECTION.
        01 EOF PIC 9 VALUE 0.
        77 UNIT-STATUS PIC X(02).
            88 UNIT-FIND VALUE '00'.
            88 UNIT-ERR VALUE '94' '98'.
        77 WS01 PIC X(01).
        77 WK-FLG PIC 99.


        PROCEDURE DIVISION.

        MAIN SECTION.
        MAIN-RTN.
            MOVE 0 TO WK-FLG.
            MOVE SPACES TO WS01.
            OPEN I-O UNIT-FILE.
            OPEN OUTPUT UNY-FILE.


                PERFORM UNTIL EOF = 1
                    READ UNIT-FILE NEXT AT END MOVE 1 TO EOF
                    END-READ
                    IF UNIT-FIND
                         ADD 1 TO WK-FLG

                         MOVE UNIT-KEY TO UNY-KEY
                         MOVE UNIT-NAME TO UNY-NAME
                         MOVE UNIT-PEOPLE TO UNY-PEOPLE
                         MOVE UNIT-MAX TO UNY-MAX
                         MOVE UNIT-FLAG TO UNY-FLAG
                         MOVE UNIT-NOTE TO UNY-NOTE
                         MOVE ',' TO XA1 XA2 XA3 XA4 XA5
                         WRITE UNY-REC
                     END-IF
                END-PERFORM.
                DISPLAY WK-FLG.

            CLOSE UNIT-FILE UNY-FILE.
            STOP RUN.

        MAIN-EXIT.
            EXIT PROGRAM.

9月 15, 2015

COBOL 顯示所有資料


        ID DIVISION.
        PROGRAM-ID. P0611.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
        COPY 'UTI\PC.FC'.
        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\PC.FD'.
        WORKING-STORAGE SECTION.
        01 EOF PIC 9 VALUE 0.
        77 PC-STATUS PIC X(02).

        77 CUT PIC 99 VALUE 0.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-RTN.
            OPEN I-O PC-FILE.
            PERFORM UNTIL EOF = 1
                READ PC-FILE NEXT AT END MOVE 1 TO EOF
                END-READ
                ADD 1 TO CUT
            END-PERFORM
            SUBTRACT 1 FROM CUT
            PERFORM CUT TIMES
                DISPLAY PC-PASSWORD PC-PROP-ID PC-STCK-ID PC-OFFICE-NAME
                DISPLAY PC-CHINESE-CODE PC-PRINTER-CODE PC-CHAR-DENSITY
                DISPLAY PC-RATE
            END-PERFORM.
            CLOSE PC-FILE.
        MAIN-EXIT.

9月 08, 2015

COBOL 讀取資料


        ID DIVISION.
        PROGRAM-ID. P0612.
        ENVIRONMENT DIVISION.
        INPUT-OUTPUT SECTION.
        FILE-CONTROL.
        COPY 'UTI\PERSON.FC'.
        DATA DIVISION.
        FILE SECTION.
        COPY 'UTI\PERSON.FD'.
        WORKING-STORAGE SECTION.
        01 EOF PIC X VALUE 'N'.
        77 PERSON-FSTATUS PIC X(02).
        77 CUT PIC 9999 VALUE 0.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-RTN.
            OPEN I-O PERSON-FILE.


                ACCEPT CUT.

                MOVE CUT TO PERSON-NO.
                READ PERSON-FILE
                END-READ.
                DISPLAY PERSON-NO PERSON-NAMEX PERSON-BANK-NO.
                DISPLAY PERSON-BIRTHDAY PERSON-MAIL-ADDR.
                DISPLAY PERSON-ARV-DATE PERSON-EDUC-XXX.
                DISPLAY PERSON-DEDUCT-DAY PERSON-DEDUCT-MONTH.
                DISPLAY PERSON-DUTY PERSON-INSURE-BEG-DATE.
                DISPLAY PERSON-INSURE-MONTH-PAY.
                DISPLAY WAGE-DATA.
                DISPLAY PERSON-PRO-SALARY-FLAG PERSON-PRO-SALARY.
                DISPLAY PERSON-PRO-PROMOTE-FLAG.



            CLOSE PERSON-FILE.
        MAIN-EXIT.

8月 02, 2015

COBOL 算術運算


        ID DIVISION.
        PROGRAM-ID. P06999.
        ENVIRONMENT DIVISION.
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 A PIC 99.
        01 B PIC 9(2) VALUE 2.
        01 C PIC 99 VALUE 30.
        01 R PIC 99 VALUE 0.
        01 DIV PIC 99V99 VALUE 00.00.
        PROCEDURE DIVISION.
        MAIN SECTION.
        MAIN-PARA.
            DISPLAY 'INPUT NUMBER'.

            ACCEPT A.
            ADD 10 A TO R.
            DISPLAY '10 + ' A '=' R.
            MOVE 20 TO R.
            SUBTRACT 10 A FROM R.
            DISPLAY '10 - ' A '=' R.
            MOVE 10 TO R.
            MULTIPLY A BY R.
            DISPLAY A ' * 10 = ' R.
            DIVIDE A BY 2 GIVING DIV.
            DISPLAY A ' / 2 =' DIV.
            MOVE 2 TO R.
            MULTIPLY A BY R GIVING DIV.
            DISPLAY A ' * 2 =' DIV.
            SUBTRACT A FROM 2 GIVING DIV.
            DISPLAY A ' - 2 =' DIV.
            ADD A TO 2 GIVING DIV ON SIZE ERROR DISPLAY 'TOO MUCH'.
            DISPLAY A ' + 2 =' DIV.
            DIVIDE 4 BY 3 GIVING DIV.
            DISPLAY '4 / 3 = ' DIV.
            COMPUTE DIV ROUNDED = 4 / 3.
            DISPLAY '4 / 3 = ' DIV.
            COMPUTE DIV = A + 2.
            DISPLAY A ' + 2 = ' DIV.
            COMPUTE DIV = A - 2.
            DISPLAY A ' - 2 = ' DIV.
            COMPUTE DIV = A / 2.
            DISPLAY A ' / 2 = ' DIV.
            COMPUTE DIV = A * 2 ON SIZE ERROR DISPLAY 'NUM IS OVER'.
            DISPLAY A ' * 2 = ' DIV.
            EXIT PROGRAM.
      

COMPUTE 输出变量 ROUNDED = 运算表达式
ROUNDED 四舍五入和输出项定义有关系
如一输出项定义99.99,一输入项为12.356
则输出为12.36,小数后第三位向前进位
如一输出项定义99,一输入项为12.356
则输出为12,小数后第第一位向前进位