tailieunhanh - 1001 Things You Wanted To Know About Visual FoxPro phần 8

1001 Những điều bạn muốn biết về Visual FoxPro Foxpro là hệ quản trị cơ sở dữ liệu dùng để giải quyết các bài toán trong các lĩnh vực quản lý. FoxPro được thừa kế và phát triển trên phần mềm DBASE III PLUS và DBASE IV, những sản phẩm nổi tiếng của hãng ASTON-TATE. Khi các công cụ lập trình và các ứng dụng trên môi trường Windows ngày nhiều thì Microsoft cho ra đời các phiên bản FoxPro , chạy được trên hai môi trường DOS và Windows. | Chapter 10 Non-Visual Classes 321 Reading the data from the specified source into the form s cursor is handled by the custom ReadFile method as follows LOCAL ARRAY laTfer 1 2 LOCAL lcSceFile lcOldFile WITH ThisForm Check the source file clear cursor if a new file is being created IF .chkSource 0 IF EMPTY ALLTRIM . Creating a new file - just return ZAP IN curIniFile .RefreshForm RETURN ENDIF ELSE Source file check failed RETURN ENDIF Specified source is OK so gather full path and file name lcSceFile ALLTRIM ADDBS . ALLTRIM . IF JUSTEXT lcSceFile DBF It s a table so just read it into an array SELECT heading item From lcSceFile ORDER BY sortorder INTO ARRAY laTfer ELSE It s an INI File maybe . So read it @laTfer lcSceFile ENDIF Clear Cursor and Copy results in ZAP IN curIniFile INSERT INTO curIniFile FROM ARRAY laTfer Strip off heading - they will be re-written anyway REPLACE ALL heading WITH CHRTRAN heading IN curIniFile .RefreshForm ENDWITH Writing the data out from the cursor is handled in the custom WriteFileO method as follows LOCAL ARRAY laTfer 1 2 LOCAL lcOldFile lcDestFile WITH ThisForm Must have a destination IF EMPTY . MESSAGEBOX An output file must be specified 16 Unable to Continue . RETURN ENDIF We have a destination lcDestFile ALLTRIM ADDBS . ALLTRIM . Delete the File if it already exists IF FILE lcDestFile DELETE FILE lcDestFile ENDIF Now create a new empty file ready for writing to We need to do this to ensure that deletions get made properly lnHnd FCREATE lcDestFile 322 1001 Things You Always Wanted to Know About Visual FoxPro IF InHnd 0 MESSAGEBOX Unable to create new file CHR 13 lcDestFile 16 Cannot Contuinue RETURN ELSE FCLOSE lnHnd ENDIF Now write the new file - ignore empty heading fields SELECT FROM curinifile WHERE EMPTY heading iNtO array laTfer WITH golniMgr Write file contents .WriteIniFile @laTfer lcDestFile