Jump to content

_FileWriteToLine ... this unknown


Adams
 Share

Recommended Posts

First of all I introduce myself ... I'm Adams and I have just joined the forum. I'm a fan of AutoIt to which I have approached a few months. But now I have one request.

Who's going to give me a hand to find out what's wrong in this script? Or rather, I already know what's wrong but I do not know why wrong and how to fix it.

In practice, what does not work is the istruction _FileWriteToLine at lines 327, 356, 404 and 482.

To test the script, prepare the environment by entering the following ".dat" file in the folder C:\ProgramData\test (which are in this folder is a requirement):

Items.dat
1;1111;Item 1111;8.89;Vendor a
2;2222;Item 2222;28.99;Vendor a
3;3333;Item 3333;9.2;Vendor b
4;4444;Item 4444;9.12;Vendor b

Items_sequence.dat
4

Suppliers.dat
1;Vendor a
2;Vendor b

Suppliers_sequence.dat
2

The Script indicted:

#include <guiconstantsex.au3>
#include <get_id.au3>
#include <guilistview.au3>
#include <listviewconstants.au3>
#include <buttonconstants.au3>
#include <file.au3>
#include <editconstants.au3>
#Include <date.au3>

;OPT
Opt("GUICloseOnESC", 0)
Opt("TrayIconHide", 1)

; Var
Global $Ver, $Errore, $Preorder_ID, $Order_ID, $Line_ID, $Code, $Description, $Quantity, $Prize, $Supplier
Global $Item_Listview, $Preorders_Listview, $Orders_Listview
Global $Sel_Button, $Add_Button, $Close_Button, $Modify_Button, $Delete_Preorders_Button, $Gen_Orders_Button
Global $Clear_Button, $View_Button, $Delete_Orders_Button, $Print_Button
Global $Items_File = @AppDataCommonDir & "testItems.dat"
Global $Preorders_File = @AppDataCommonDir & "testPreorders.dat"
Global $Orders_File = @AppDataCommonDir & "testOrders.dat"
Global $Order_Lines_File = @AppDataCommonDir & "testOrderlines.dat"
Dim $Fields_Items, $Fields_Preorders, $Fields_Orders, $Fields_Order_Lines

#cs
$Items_File
$Fields_Items[1] ; Item_ID
$Fields_Items[2] ; Codice
$Fields_Items[3] ; Descrizione
$Fields_Items[4] ; Prezzo
$Fields_Items[5] ; Fornitore
$Fields_Items[6] ; Sconto (future use)

$Preorders_File
$Fields_Preorders[1] ; Preorder_ID
$Fields_Preorders[2] ; Codice
$Fields_Preorders[3] ; Descrizione
$Fields_Preorders[4] ; Quantità
$Fields_Preorders[5] ; Prezzo
$Fields_Preorders[6] ; Fornitore
$Fields_Preorders[7] ; Sconto (future use)

$Orders_File
$Fields_Orders[1] ; Order_ID
$Fields_Orders[2] ; Data_Ordine
$Fields_Orders[3] ; Fornitore
$Fields_Orders[4] ; Ordine_Completo
$Fields_Orders[5] ; Sconto (future use)
$Fields_Orders[6] ; file (future use)

$Order_Lines_File
$Fields_Order_Lines[1] ; Line_ID
$Fields_Order_Lines[2] ; Order_ID
$Fields_Order_Lines[3] ; Preorder_ID
$Fields_Order_Lines[4] ; Codice
$Fields_Order_Lines[5] ; Descrizione
$Fields_Order_Lines[6] ; Quantità
$Fields_Order_Lines[7] ; Prezzo
$Fields_Order_Lines[8] ; Sconto (future use)
#ce

; GUI
GUICreate("Orders (C) 2009 by Adams", 575, 800)
$Ver = GUICtrlCreateLabel("v0.3.0", 5, 785, 30, 15)
GUICtrlSetColor($Ver, 0x5d5d5d) ; grayed
GUICtrlSetBkColor($Ver, $GUI_BKCOLOR_TRANSPARENT)

; GROUP 1 Anagrafica articoli
GUICtrlCreateGroup("Items",5,80,565,160)

; LISTVIEW Articoli Selezionati
$Items_Listview = GUICtrlCreateListView("ID|Code |Description|Price |Vendor ",10,100,555,90,-1,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
_load_items()

; BUTTON Seleziona
$Sel_Button = GuiCtrlCreateButton("&Select",465,200,100,30)

; GROUP 2 Riga preordine
GUICtrlCreateGroup("Preorder line",5,250,565,110)

; ID non esposto a video
$Preorder_ID = ""

; INPUT Codice
GUICtrlCreateLabel("Code", 14, 270, 50, 20)
$Code = GUICtrlCreateInput("", 10, 290, 100, 20,$ES_READONLY)

; INPUT Descrizione
GUICtrlCreateLabel("Description", 119, 270, 60, 20)
$Description = GUICtrlCreateInput("", 115, 290, 200, 20,$ES_READONLY)

; INPUT Quantità
GUICtrlCreateLabel("Quantity", 324, 270, 50, 20)
$Quantity = GUICtrlCreateInput("", 320, 290, 50, 20)

; INPUT Prezzo
GuiCtrlCreateLabel("Price", 379, 270, 50, 20)
$Prize = GuiCtrlCreateInput("", 375, 290, 50, 20)

; INPUT Fornitore
GUICtrlCreateLabel("Vendor", 434, 270, 60, 20)
$Supplier = GUICtrlCreateInput("", 430, 290, 135, 20,$ES_READONLY)

; BUTTON Salva
$Add_Button = GUICtrlCreateButton("Add", 465, 320, 100, 30)

; BUTTON Clear
$Clear_Button = GUICtrlCreateButton("Clear", 355, 320, 100, 30)

; GROUP 3 Preordini
GUICtrlCreateGroup("Preorders",5,370,565,170)

; LISTVIEW Preordini (il control viene inizializzato direttamente nella funzione)
_load_preorders()

; BUTTON Modifica
$Modify_Button = GuiCtrlCreateButton("Change",245,500,100,30)

; BUTTON Cancella
$Delete_Preorders_Button = GuiCtrlCreateButton("Delete",355,500,100,30)

; BUTTON Genera ordini
$Gen_Orders_Button = GuiCtrlCreateButton("Create Orders",465,500,100,30)

; GROUP 4 Ordini
GUICtrlCreateGroup("Orders",5,550,565,170)

; LISTVIEW Ordini
$Orders_Listview = GUICtrlCreateListView("ID|Date|Vendor |Complete",10,570,555,100,-1,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
_load_orders()

; BUTTON Stampa
$Print_Button = GuiCtrlCreateButton("Print",245,680,100,30)

; BUTTON Vedi
$View_Button = GuiCtrlCreateButton("Display",355,680,100,30)

; BUTTON Cancella
$Delete_Orders_Button = GuiCtrlCreateButton("Delete",465,680,100,30)

; BUTTON Esci
$Close_Button = GuiCtrlCreateButton("Exit",465,760,100,30)

; GUI MESSAGE LOOP
GUISetState()
While 1
$Msg = GUIGetMsg()
Select
Case $Msg = $Sel_Button
If GUICtrlRead(GUICtrlRead($Items_Listview)) <> "" Then
$aItems_List_Line = StringSplit(GUICtrlRead(GUICtrlRead($Items_Listview)), "|", 1)
$Preorder_ID = ""
GUICtrlSetData($Code, $aItems_List_Line[2])
GUICtrlSetData($Description, $aItems_List_Line[3])
GUICtrlSetData($Quantity, "")
GUICtrlSetData($Prize, $aItems_List_Line[4])
GUICtrlSetData($Supplier, $aItems_List_Line[5])
GUICtrlSetData($Add_Button, "Add")
EndIf
Case $Msg = $Add_Button
$Errore = ""
_check_items()
If $Errore = "" Then
_save()
EndIf
Case $Msg = $Clear_Button
$Preorder_ID = ""
GUICtrlSetData($Code, "")
GUICtrlSetData($Description, "")
GUICtrlSetData($Quantity, "")
GUICtrlSetData($Prize, "")
GUICtrlSetData($Supplier, "")
GUICtrlSetData($Add_Button, "Add")
Case $Msg = $Modify_Button
If GUICtrlRead(GUICtrlRead($Preorders_Listview)) <> "" Then
$aPreorders_List_Line = StringSplit(GUICtrlRead(GUICtrlRead($Preorders_Listview)), "|", 1)
$Preorder_ID = $aPreorders_List_Line[1]
GUICtrlSetData($Code, $aPreorders_List_Line[2])
GUICtrlSetData($Description, $aPreorders_List_Line[3])
GUICtrlSetData($Quantity, $aPreorders_List_Line[4])
GUICtrlSetData($Prize, $aPreorders_List_Line[5])
GUICtrlSetData($Supplier, $aPreorders_List_Line[6])
GUICtrlSetData($Add_Button, "Update")
EndIf
Case $Msg = $Delete_Preorders_Button
If GUICtrlRead(GUICtrlRead($Preorders_Listview)) <> "" Then
$aPreorders_List_Line = StringSplit(GUICtrlRead(GUICtrlRead($Preorders_Listview)), "|", 1)
$Preorder_ID = $aPreorders_List_Line[1]
_delete_preorder()
EndIf
Case $Msg = $Gen_Orders_Button
$Errore = ""
_check_preorders()
If $Errore = "" Then
_create_orders()
EndIf
Case $Msg = $Print_Button
_print()
Case $Msg = $View_Button
_view()
Case $Msg = $Delete_Orders_Button
If GUICtrlRead(GUICtrlRead($Orders_Listview)) <> "" Then
$aOrders_List_Line = StringSplit(GUICtrlRead(GUICtrlRead($Orders_Listview)), "|", 1)
$Order_ID = $aOrders_List_Line[1]
_delete_order_lines()
_delete_order()
EndIf
Case $Msg = $Close_Button
ExitLoop
Case $Msg = $GUI_EVENT_CLOSE
ExitLoop
EndSelect
WEnd

Func _load_items()
If FileExists($Items_File) Then
$Handle_Items_R = FileOpen($Items_File, 0)
If $Handle_Items_R = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open items file.")
Exit
EndIf
While 1
$Rec_Items = FileReadLine($Handle_Items_R)
If @error = -1 Then ExitLoop
$Fields_Items = StringSplit($Rec_Items, ";", 1)
GUICtrlCreateListViewItem($Fields_Items[1] & "|" & $Fields_Items[2] & "|" & $Fields_Items[3] & "|" & $Fields_Items[4] & "|" & $Fields_Items[5],$Items_Listview)
WEnd
FileClose($Handle_Items_R)
EndIf
EndFunc

Func _load_preorders()
; elimino e ricreo la lista preordini
GUICtrlDelete($Preorders_Listview)
$Preorders_Listview = GUICtrlCreateListView("ID |Code |Description |Quantity|Price |Vendor ",10,390,555,100,-1,BitOR($LVS_EX_GRIDLINES,$LVS_EX_FULLROWSELECT))
If FileExists($Preorders_File) Then
$Handle_Preorders_R = FileOpen($Preorders_File, 0)
If $Handle_Preorders_R = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file.")
Exit
EndIf
While 1
$Rec_Preorders = FileReadLine($Handle_Preorders_R)
If @error = -1 Then ExitLoop
$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)
GUICtrlCreateListViewItem($Fields_Preorders[1] & "|" & $Fields_Preorders[2] & "|" & $Fields_Preorders[3] & "|" & $Fields_Preorders[4] & "|" & $Fields_Preorders[5] & "|" & $Fields_Preorders[6],$Preorders_Listview)
WEnd
FileClose($Handle_Preorders_R)
EndIf
EndFunc

Func _load_orders()
If FileExists($Orders_File) Then
$Handle_Orders_R = FileOpen($Orders_File, 0)
If $Handle_Orders_R = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open orders file.")
Exit
EndIf
While 1
$Rec_Orders = FileReadLine($Handle_Orders_R)
If @error = -1 Then ExitLoop
$Fields_Orders = StringSplit($Rec_Orders, ";", 1)
Select
Case $Fields_Orders[4] = "1"
$Status = "Complete"
Case Else
$Status = "Open"
EndSelect
GUICtrlCreateListViewItem($Fields_Orders[1] & "|" & $Fields_Orders[2] & "|" & $Fields_Orders[3] & "|" & $Status,$Orders_Listview)
WEnd
FileClose($Handle_Orders_R)
EndIf
EndFunc

Func _check_items()
GUICtrlSetBkColor($Quantity, 0xffffff) ; bianco
GUICtrlSetBkColor($Prize, 0xffffff) ; bianco
If GUICtrlRead($Code) = "" And $Errore = "" Then
MsgBox(0,"Errore", "Select an item or a preorder line.")
$Errore = "1"
EndIf

If GUICtrlRead($Quantity) = 0 And $Errore = "" Then
MsgBox(0,"Error", "Type a valid quantity.")
GUICtrlSetBkColor($Quantity, 0xffff80) ; giallo
GUICtrlSetState($Quantity, $GUI_FOCUS)
$Errore = "1"
EndIf
If GUICtrlRead($Prize) = 0 And $Errore = "" Then
MsgBox(0,"Error", "Type a valid price.")
GUICtrlSetBkColor($Prize, 0xffff80) ; giallo
GUICtrlSetState($Prize, $GUI_FOCUS)
$Errore = "1"
EndIf
EndFunc

Func _save()
Local $Rec_Preorders_Count = 0
Select
Case $Preorder_ID = "" ; Scrittura file
$Handle_Preorders_W = FileOpen($Preorders_File, 1)
If $Handle_Preorders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file.")
Exit
EndIf
$Preorder_ID = _get_id("Preorders", @AppDataCommonDir & "test")
$Rec_Preorders = $Preorder_ID & ";" & GUICtrlRead($Code) & ";" & GUICtrlRead($Description) & ";" & GUICtrlRead($Quantity) & ";" & GUICtrlRead($Prize) & ";" & GUICtrlRead($Supplier)
FileWriteLine($Handle_Preorders_W, $Rec_Preorders)
FileClose($Handle_Preorders_W)
GUICtrlCreateListViewItem($Preorder_ID & "|" & GUICtrlRead($Code) & "|" & GUICtrlRead($Description) & "|" & GUICtrlRead($Quantity) & "|" & GUICtrlRead($Prize) & "|" & GUICtrlRead($Supplier),$Preorders_Listview)
Case Else ; Aggiornamento file
$Handle_Preorders_W = FileOpen($Preorders_File, 0)
If $Handle_Preorders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file.")
Exit
EndIf
While 1
$Rec_Preorders = FileReadLine($Handle_Preorders_W)
$Rec_Preorders_Count += 1
If @error = -1 Then ExitLoop
$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)
If $Preorder_ID = $Fields_Preorders[1] Then ExitLoop
WEnd
$Preorders_Path = $Preorders_File
$Rec_Preorders = $Preorder_ID & ";" & GUICtrlRead($Code) & ";" & GUICtrlRead($Description) & ";" & GUICtrlRead($Quantity) & ";" & GUICtrlRead($Prize) & ";" & GUICtrlRead($Supplier)
MsgBox(0, "Debug", $Preorders_Path & @CRLF & $Rec_Preorders_Count & @CRLF & $Rec_Preorders)
_FileWriteToLine($Preorders_Path, $Rec_Preorders_Count, $Rec_Preorders, 1)
GUICtrlSetData(GUICtrlRead($Preorders_Listview), $Preorder_ID & "|" & GUICtrlRead($Code) & "|" & GUICtrlRead($Description) & "|" & GUICtrlRead($Quantity) & "|" & GUICtrlRead($Prize) & "|" & GUICtrlRead($Supplier))
EndSelect
;Pulizia campi
$Preorder_ID = ""
GUICtrlSetData($Code, "")
GUICtrlSetData($Description, "")
GUICtrlSetData($Quantity, "")
GUICtrlSetData($Prize, "")
GUICtrlSetData($Supplier, "")
GUICtrlSetData($Add_Button, "Add")
EndFunc

Func _delete_preorder()
Local $Rec_Preorders_Count = 0
$Handle_Preorders_W = FileOpen($Preorders_File, 0)
If $Handle_Preorders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file")
Exit
EndIf
While 1
$Rec_Preorders = FileReadLine($Handle_Preorders_W)
$Rec_Preorders_Count += 1
If @error = -1 Then ExitLoop
$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)
If $Preorder_ID = $Fields_Preorders[1] Then ExitLoop
WEnd
$Preorders_Path = $Preorders_File
MsgBox(0, "Debug", $Preorders_Path & @CRLF & $Rec_Preorders_Count)
_FileWriteToLine($Preorders_Path, $Rec_Preorders_Count, "", 1)
GUICtrlDelete(GUICtrlRead($Preorders_Listview))
;Pulizia campi
$Preorder_ID = ""
GUICtrlSetData($Code, "")
GUICtrlSetData($Description, "")
GUICtrlSetData($Quantity, "")
GUICtrlSetData($Prize, "")
GUICtrlSetData($Supplier, "")
GUICtrlSetData($Add_Button, "Add")
EndFunc

Func _check_preorders()
If FileExists($Preorders_File) Then
$Handle_Preorders_R = FileOpen($Preorders_File, 0)
If $Handle_Preorders_R = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file.")
Exit
EndIf
While 1
$Rec_Preorders = FileReadLine($Handle_Preorders_R) ;leggo un solo record per controllo
ExitLoop
WEnd
FileClose($Handle_Preorders_R)
If $Rec_Preorders = "" Then
MsgBox(0,"Error", "Not exist any preorder line.")
$Errore = "1"
EndIf
Else
MsgBox(0,"Error", "Not exist any preorder line.")
$Errore = "1"
EndIf
EndFunc

Func _create_orders()
Local $Rec_Preorders_Count = 0
$Handle_Preorders_W = FileOpen($Preorders_File, 0)
If $Handle_Preorders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open preorders file.")
Exit
EndIf
While 1
$Rec_Preorders = FileReadLine($Handle_Preorders_W)
If @error = -1 Then ExitLoop
$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)
_get_order()
_create_lines()
$Preorders_Path = $Preorders_File
_FileWriteToLine($Preorders_Path, 1, "",1 ) ; riga = 1 perchè cancellando una riga la successiva sale
WEnd
_load_preorders()
EndFunc

Func _get_order()
If FileExists($Orders_File) Then
$Handle_Orders_R = FileOpen($Orders_File, 0)
If $Handle_Orders_R = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open orders file.")
Exit
EndIf
While 1
$Rec_Orders = FileReadLine($Handle_Orders_R)
If @error = -1 Then ExitLoop
$Fields_Orders = StringSplit($Rec_Orders, ";", 1)
If $Fields_Preorders[6] = $Fields_Orders[3] And $Fields_Orders[4] = "" Then ExitLoop
WEnd
FileClose($Handle_Orders_R)
If $Fields_Preorders[6] = $Fields_Orders[3] And $Fields_Orders[4] = "" Then
$Order_ID = $Fields_Orders[1]
Else
_create_header()
EndIf
Else
_create_header()
EndIf
EndFunc

Func _create_header()
$Handle_Orders_W = FileOpen($Orders_File, 1)
If $Handle_Orders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open orders file.")
Exit
EndIf
$Order_ID = _get_id("Orders", @AppDataCommonDir & "test")
$Rec_Orders = $Order_ID & ";" & _NowDate() & ";" & $Fields_Preorders[6] & ";" & ""
FileWriteLine($Handle_Orders_W, $Rec_Orders)
FileClose($Handle_Orders_W)
GUICtrlCreateListViewItem($Order_ID & "|" & _NowDate() & "|" & $Fields_Preorders[6] & "|" & "Open",$Orders_Listview)
EndFunc

Func _create_lines()
$Handle_Order_Lines_W = FileOpen($Order_Lines_File, 1)
If $Handle_Order_Lines_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open order lines file.")
Exit
EndIf
$Line_ID = _get_id("Orderlines", @AppDataCommonDir & "test")
$Rec_Order_lines = $Line_ID & ";" & $Order_ID & ";" & $Fields_Preorders[1] & ";" & $Fields_Preorders[2] & ";" & $Fields_Preorders[3] & ";" & $Fields_Preorders[4] & ";" & $Fields_Preorders[5]
FileWriteLine($Handle_Order_Lines_W, $Rec_Order_lines)
FileClose($Handle_Order_Lines_W)
EndFunc

Func _print()
MsgBox(0, "info", "function not yet implemented")
EndFunc

Func _view()
; si deve prima verificare che l'ordine sia stato stampato
MsgBox(0, "info", "function not yet implemented")
EndFunc

Func _delete_order()
Local $Rec_Orders_Count = 0
$Handle_Orders_W = FileOpen($Orders_File, 0)
If $Handle_Orders_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open orders file.")
Exit
EndIf
While 1
$Rec_Orders = FileReadLine($Handle_Orders_W)
$Rec_Orders_Count += 1
If @error = -1 Then ExitLoop
$Fields_Orders = StringSplit($Rec_Orders, ";", 1)
If $Order_ID = $Fields_Orders[1] Then ExitLoop
WEnd
$Orders_Path = $Orders_File
_FileWriteToLine($Orders_Path, $Rec_Orders_Count, "", 1)
GUICtrlDelete(GUICtrlRead($Orders_Listview))
;Pulizia campi
$Order_ID = ""
EndFunc

Func _delete_order_lines()
Local $Rec_Order_lines_Count = 0
$Handle_Order_Lines_W = FileOpen($Order_Lines_File, 0)
If $Handle_Order_Lines_W = -1 Then ; Check if file opened for reading OK
MsgBox(0, "Error", "Unable to open order lines file.")
Exit
EndIf
While 1
$Rec_Order_lines = FileReadLine($Handle_Order_Lines_W)
$Rec_Order_lines_Count += 1
If @error = -1 Then ExitLoop
$Fields_Order_Lines = StringSplit($Rec_Order_lines, ";", 1)
If $Order_ID = $Fields_Order_Lines[2] Then
$Order_Lines_Path = $Order_Lines_File
_FileWriteToLine($Order_Lines_Path, $Rec_Order_lines_Count, "", 1)
$Rec_Order_lines_Count -= 1
EndIf
WEnd
EndFunc

The operational is simple:

- Select an item from the "items" section, this will be brought in "preorder line" section.

- in "preorder line add" section, add the quantity and click on "add" button, this will lead the line in "preorders" section.

- in "preorders" section click on "Create Orders" button (of course after you have inserted several lines of preorders), you get "n" orders in the "orders" section, one per supplier.

This is all. Now, if you want change a quantity in a "preorders", you must click on "change" button. That shows the line in "preorder line" section. Here change the quantity and click "Update" button. Visually the row is updated in "preorders" but is not properly updated the file (if you get out and come back you'll see that the values are those before). Likewise, if I want to delete a line of preorder or an order (buttons "delete"), the cancellation does not occur.

Thanks for any suggestions

Edited by Adams

Adams

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

LOL. I'm forgetful. Monday, from the office, I will upload the udf "get_id" (really simple). Meanwhile, thanks for the suggestions that I will certainly take into consideration.

Edited by Adams

Adams

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

... Sorry. But I have decided to take a break from this topic. I don't mean this in a bad way to you, I just lost the needed interest to continue at the moment.

But at leased this way others that might read this might jump in. Good luck.

thanks anyway MvGulik.

here is a zip file containing the data file for those who want to test.

test.zip

Adams

Link to comment
Share on other sites

thanks anyway MvGulik.

here is a zip file containing the data file for those who want to test.

wouldnt it be easier to change from .dat to .ini

then u woulnd need to stumble with so many fileopen, just iniwrite and iniread

p.s. i think that there in ure current script is a conflict where u have opened that file in read mode, and then its not possible to do the writeline thingy

GL!

Link to comment
Share on other sites

btw all this of ures:

While 1

$Rec_Preorders = FileReadLine($Handle_Preorders_W)

$Rec_Preorders_Count += 1

If @error = -1 Then ExitLoop

$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)

If $Preorder_ID = $Fields_Preorders[1] Then ExitLoop

WEnd

$Preorders_Path = $Preorders_File

$Rec_Preorders = $Preorder_ID & ";" & GUICtrlRead($Code) & ";" & GUICtrlRead($Description) & ";" & GUICtrlRead($Quantity) & ";" & GUICtrlRead($Prize) & ";" & GUICtrlRead($Supplier)

MsgBox(0, "Debug", $Preorders_Path & @CRLF & $Rec_Preorders_Count & @CRLF & $Rec_Preorders)

_FileWriteToLine($Preorders_Path, $Rec_Preorders_Count, $Rec_Preorders, 1)

could be done with simple-stright if u go for ini,:

iniwrite($inifiledestination, $Preorder_ID, "Quantity", GUICtrlRead($Quantity))

iniwrite($inifiledestination, $Preorder_ID, "Prize", GUICtrlRead($Prize))

Link to comment
Share on other sites

whatever Edited by MvGulik

"Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions."
"The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014)

"Believing what you know ain't so" ...

Knock Knock ...
 

Link to comment
Share on other sites

I would strongly recommend not to use the INI system for things its not designed for. Your just going to set yourself up to run into trouble later on. (32k size limit for one) Rewrite INI-Functions

If the normal file system becomes to troublesome for whatever data your processing, look at something like SQLite as possible alternative. (AutoIt comes with its own SQLite support(UDF&Help))

True.

Thou, if the orders get accomplished before they reach a ton, that would be still a solution - at least like a step before bigger jump (and how it looks to me - the GUI isn't very likely to be hundreds*n order friendly, i think there is a possibility, where ini wouldn't reach 32k )

Link to comment
Share on other sites

thanks anyway MvGulik.

here is a zip file containing the data file for those who want to test.

SUccess - managed to change 1 preorder to 2 preorder (if im not mistaken this was ure stuck point)

in ure _save function change the ending with this:

While 1

$Rec_Preorders = FileReadLine($Handle_Preorders_W)

$Rec_Preorders_Count += 1

If @error = -1 Then ExitLoop

$Fields_Preorders = StringSplit($Rec_Preorders, ";", 1)

If $Preorder_ID = $Fields_Preorders[1] Then ExitLoop

WEnd

fileclose($Handle_Preorders_W)

$Rec_Preorders = $Preorder_ID & ";" & GUICtrlRead($Code) & ";" & GUICtrlRead($Description) & ";" & GUICtrlRead($Quantity) & ";" & GUICtrlRead($Prize) & ";" & GUICtrlRead($Supplier)

;MsgBox(0, "Debug " & GUICtrlRead($Quantity), $Preorders_Path2 & @CRLF & $Rec_Preorders_Count & @CRLF & $Rec_Preorders)

_FileWriteToLine("C:\Program Files\test\Preorders.dat", $Rec_Preorders_Count, $Rec_Preorders, 1)

GUICtrlSetData(GUICtrlRead($Preorders_Listview), $Preorder_ID & "|" & GUICtrlRead($Code) & "|" & GUICtrlRead($Description) & "|" & GUICtrlRead($Quantity) & "|" & GUICtrlRead($Prize) & "|" & GUICtrlRead($Supplier))

EndSelect

;Pulizia campi

$Preorder_ID = ""

GUICtrlSetData($Code, "")

GUICtrlSetData($Description, "")

GUICtrlSetData($Quantity, "")

GUICtrlSetData($Prize, "")

GUICtrlSetData($Supplier, "")

GUICtrlSetData($Add_Button, "Add")

EndFunc

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...