פורסם 2009 באוגוסט 3016 שנים אהלן,אני צריך לכתוב ב-VB סקריפט, אפשר להגדיר את זה כ-PRE PROCESS, שאני מקבל קובץ כלשהו, אחרי 79 שורות אני צריך לכתוב לשם ASCII CODE של שבירת עמוד (יש לי את ה-ASCII CODE). האם למישהו יש המלצה מאיפה להתחיל?
פורסם 2009 בספטמבר 116 שנים העבודה עם קבצים בVBSCRIPT די מסורבלת בגלל שיש רק שלושה מצבי עבודה, או קריאה בלבד, או כתיבה שאז כל הקובץ נמחק ונוצר מחדש, או append המאפשר כתיבה לסוף הקובץ.לכן מה שאני בד"כ עושה הוא קורא את כל הקובץ לתוך משתנה, חותך אותו למערך ע"י split, משנה את השורה שאני רוצה, ומחבר חזרה ע"י join.Const ForWriting = 2, ForReading = 1, FormatUnicoe = -1, FormatASCII = 0'path for your filestrFilePath = "C:\Documents and Settings\Administrator\Desktop\example.txt"'ascii codeintASCIICode = 12'create file system object and open text file for reading.Set objFileSystem = CreateObject("Scripting.FileSystemObject")Set objTextStream = objFileSystem.OpenTextFile(strFilePath, ForReading, false, FormatASCII)'read content and close streamstrContent = objTextStream.ReadAllobjTextStream.close'split content to array, each array element will hold 1 linearrContent = Split(strContent, Chr(13) & Chr(10))'edit the begining of line 80arrContent(79) = Chr(intASCIICode) & arrContent(79)'join array againstrContent = Join(arrContent, Chr(13) & Chr(10))'open file for writing and write the content and close streamSet objTextStream = objFileSystem.OpenTextFile(strFilePath, ForWriting, false, FormatASCII)objTextStream.Write(strContent)objTextStream.closeזהו פחות או יותר..
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.