1 / 14

קבצים ב VB-

קבצים ב VB-. במקרים מסוימים יהיה צורך לאחסן ולאחזר נתונים מבלי להידרש לעוצמה של מסד נתונים. במקרים כאלה, קבצי טקסט יהוו את הפתרון הרצוי. קבצי טקסט. גישות לקבצים. קיימים שלושה סוגי גישה לקבצים: 1. גישה סדרתית - Sequential Access 2. גישה אקראית - Random Access

davin
Download Presentation

קבצים ב VB-

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. קבצים ב VB-

  2. במקרים מסוימים יהיה צורך לאחסן ולאחזר נתונים מבלי להידרש לעוצמה של מסד נתונים. במקרים כאלה, קבצי טקסט יהוו את הפתרון הרצוי. קבצי טקסט

  3. גישות לקבצים קיימים שלושה סוגי גישה לקבצים: 1. גישה סדרתית - Sequential Access 2. גישה אקראית - Random Access 3. גישה בינרית - Binary Access

  4. לקבצים סדרתיים אין מבנה מסודר כלשהו. פתיחת קובץ לקריאה (input), לכתיבה (Output) ולהוספה (Append) Open pathname for [input|Output|Append] As filenumber [len=buffersize] פתיחת קובץ לא קיים לקריאה תהווה שגיאה פתיחת קובץ לא קיים לכתיבה או הוספה, תיצור אותו. גישה סדרתית - פתיחת קובץ

  5. Line input # filenum, line קריאת שורה מהקובץ input #filenum,str,int,date קריאה לתוך משתנים מתאימים. פ’ זו מחפשת את תווי ההפרדה (פסיקים, גרשיים, ו-#) “text”,100,#1999-12-31# str=Input(chnum,#filenum) קריאת chnumתווים מקובץ filenum str=input(4,#filenum) קורא 4 תווים מהקובץ גישה סדרתית - קריאה מקובץ

  6. Print #filenum, “hello” hello write #filenum “hello” “hello” גישה סדרתית - כתיבה לקובץ

  7. גישה אקראית מתאימה לקבצים המכילים רשומות בעלי אורך ומבנה זהים Type worker lastname as string*10 title as string*7 rank as string*2 End Type public employee as worker גישה אקראית

  8. Open pathname [for random] As filenumber len=buffersize הגישה האקראית היא ברירת המחדל, לכן לא חייבים לכתוב for random reclen=len(employee) filenum=freefile open “myfile.txt” as filenum len=reclen גישה אקראית - פתיחת קובץ

  9. קריאת רשומות למשתנים Get filenum, position, employee positionמכיל מספר הרשומה get #1,1,employee כתיבת משתנים לרשומות Put #filenum,position,employee משתמשים במשפט seek כדי לעבור בין רשומות בקובץ seek #1,3 משפט get או put הבא יתייחס לרשומה מספר 3 גישה אקראית - קריאה וכתיבה

  10. Open phathname [for random] as filenumber len=reclen reclen=len(Employee) filenum=freefile ‘ get the next available number Open “myfile” as filenum len=reclen Opening File For Random Access

  11. Reading Records into variables Get filenum, position, Employee Writing variables to record Replacing Records put #filenum,position,Employee Adding Records lastrecord = last record + 1 put #filenum,lastrecord,Employee Editing File For Random Access

  12. Reading Records into variables Get filenum, position, Employee Writing variables to record Replacing Records put #filenum,position,Employee Adding Records lastrecord = last record + 1 put #filenum,lastrecord,Employee Editing File For Random Access

  13. הגישה הבינרית מאפשרת שליטה מוחלטת על הקובץ. ה- bytes בקובץ יכולים לייצג כל דבר. בגישה הבינרית משתמשים כאשר חשוב לשמור על גודל קובץ קטן Open pathname for binary As filenumber גישה בינרית

  14. file copy source, dest kill path name oldname as newname mkdir pathname rmdir pathname chdir pathname chdrive drive strvar=dir(path[,attr]) if dir$(“c:\myfile.txt”)=“” then ... Strvar=cyrdir$([drive]) יחזיר את שם התיקיה הפעילה close #filenum הפונקציה shellלהפעלת תוכניות נוספות doublevar=shell(pathname[,winstyle]) dtaskid=shell(notepad d:\readme.txt”, vbnormalfocus) פונקציות על קבצים

More Related