Я запускаю приведенный ниже скрипт в системе ERP. Он импортирует данные из текстового файла и создает счета в системе. Однако после ~ 50 счетов-фактур память будет превышена, и сценарий остановится. Что я могу изменить, чтобы использовать меньше памяти в операции?
var file_name = Recordset.Fields(0).Value
var file_sys = new ActiveXObject("Scripting.FileSystemObject")
var file = file_sys.OpenTextFile(file_name)
while (!file.AtEndOfStream)
\{
var text = file.ReadLine()
if (text.search("FV/FIRMA_") != -1)
\{
pos_1 = text.indexOf(String.fromCharCode(44))+1
pos_2 = text.indexOf(String.fromCharCode(44),pos_1)+1
pos_3 = text.indexOf(String.fromCharCode(44),pos_2)+1
pos_4 = text.indexOf(String.fromCharCode(44),pos_3)+1
pos_5 = text.indexOf(String.fromCharCode(44),pos_4)+1
pos_6 = text.indexOf(String.fromCharCode(44),pos_5)+1
pos_7 = text.indexOf(String.fromCharCode(44),pos_6)+1
pos_8 = text.indexOf(String.fromCharCode(44),pos_7)+1
pos_9 = text.indexOf(String.fromCharCode(44),pos_8)+1
pos_10 = text.indexOf(String.fromCharCode(44),pos_9)+1
pos_11 = text.indexOf(String.fromCharCode(44),pos_10)+1
pos_12 = text.indexOf(String.fromCharCode(44),pos_11)+1
pos_13 = text.indexOf(String.fromCharCode(44),pos_12)+1
dok_data = text.substring(pos_1+1,pos_2-2)
dok_nr = text.substring(pos_2+1,pos_3-2)
dok_brutto = text.substring(pos_5,pos_6-1)
dok_netto = Number(text.substring(pos_6,pos_7-1))
dok_vat = Number(text.substring(pos_7,pos_8-1))
cus_name = text.substring(pos_9+1,pos_10-2)
cus_street = text.substring(pos_10+1,pos_11-2)
cus_zipcode = text.substring(pos_11+1,pos_12-2)
cus_city = text.substring(pos_12+1,pos_13-2)
var Vat = Session.CreateObject("Invoices").AddNew()
Vat.Dokument = dok_nr
Vat.DataZap = dok_data
var rejestr
if (dok_nr.search("FV/FIRMA_INT") != -1)\{ rejestr="INT SPRZEDAZ" \}
if (dok_nr.search("FV/FIRMA_TV") != -1)\{ rejestr="TVK" \}
Vat.Rejestr = rejestr
var category
if (dok_nr.search("FV/FIRMA_INT") != -1)\{ category = 121\}\{ category2 = 201\}
if (dok_nr.search("FV/FIRMA_TV") != -1)\{ category = 114\}\{ category2 = 200\}
Vat.category = Session.CreateObject("Categories").Item("Cat_CatId='"+category+"'")
kontrahent = 1
Vat.Podmiot = Session.CreateObject("Customers").Item("Cus_CusId='"+kontrahent+"'")
Vat.Podmiot.Name = cus_name
Vat.Podmiot.Adres.street = cus_street
Vat.Podmiot.Adres.city = cus_city
Vat.Podmiot.Adres.zipcode = cus_zipcode
pm=3
Vat.FormaPlatnosci = Session.CreateObject("PaymentMethods").Item("PMe_PMeId='"+pm+"'")
var Element
Element = Vat.Elementy.AddNew()
Element.Netto = dok_netto
Element.Vat = dok_vat
Session.Save()
\}
\}
file.Close()
Любая помощь очень ценится!
С уважением, Przemek