البرمجة

تخزين متغيرات المصفوفة في ملف .ini

To store two array variables in a configuration (.ini) file in VBScript, you can encode the arrays as strings and then decode them back into arrays when reading from the file. Here’s how you can modify your VBScript to achieve this:

First, convert the arrays to strings before writing them to the .ini file:

vbscript
strReportPath = "/davaoccc,/calambaccc,/cebuccc" strFilePut = "0970*.txt,0979*.txt,0983*.txt" ' Write the arrays as strings to the .ini file WriteIni strIniFilePath, "FTP", "ReportPath", strReportPath WriteIni strIniFilePath, "FTP", "FilePut", strFilePut

Then, modify your script to read the arrays as strings from the .ini file and convert them back to arrays:

vbscript
' Read the arrays as strings from the .ini file strReportPath = Split(ReadIni(strIniFilePath, "FTP", "ReportPath"), ",") strFilePut = Split(ReadIni(strIniFilePath, "FTP", "FilePut"), ",") ' Loop through the arrays and process each item For i = 0 To UBound(strReportPath) ' Your existing code here ' You can use strReportPath(i) and strFilePut(i) as needed Next

In this approach, the arrays strReportPath and strFilePut are converted to strings using the Join function before writing them to the .ini file, and then converted back to arrays using the Split function when reading from the .ini file. This way, the arrays are stored in the .ini file and can be retrieved correctly.

المزيد من المعلومات

لتخزين متغيري مصفوفة في ملف تكوين (.ini) في VBScript ، يمكنك تشفير المصفوفات كسلاسل ومن ثم فك تشفيرها مرة أخرى إلى مصفوفات عند القراءة من الملف. هنا كيف يمكنك تعديل سكريبت VBScript الخاص بك لتحقيق ذلك:

أولاً ، قم بتحويل المصفوفات إلى سلاسل قبل كتابتها في ملف .ini:

vbscript
strReportPath = "/davaoccc,/calambaccc,/cebuccc" strFilePut = "0970*.txt,0979*.txt,0983*.txt" ' Write the arrays as strings to the .ini file WriteIni strIniFilePath, "FTP", "ReportPath", strReportPath WriteIni strIniFilePath, "FTP", "FilePut", strFilePut

ثم ، قم بتعديل السكريبت الخاص بك لقراءة المصفوفات كسلاسل من ملف .ini وتحويلها مرة أخرى إلى مصفوفات:

vbscript
' Read the arrays as strings from the .ini file strReportPath = Split(ReadIni(strIniFilePath, "FTP", "ReportPath"), ",") strFilePut = Split(ReadIni(strIniFilePath, "FTP", "FilePut"), ",") ' Loop through the arrays and process each item For i = 0 To UBound(strReportPath) ' Your existing code here ' You can use strReportPath(i) and strFilePut(i) as needed Next

بهذه الطريقة ، يتم تحويل المصفوفات strReportPath و strFilePut إلى سلاسل باستخدام الدالة Join قبل كتابتها في ملف .ini ، ثم يتم تحويلها مرة أخرى إلى مصفوفات باستخدام الدالة Split عند القراءة من الملف .ini. بهذه الطريقة ، يتم تخزين المصفوفات في ملف .ini ويمكن استرجاعها بشكل صحيح.

زر الذهاب إلى الأعلى