onestcoder Posted August 15, 2008 Posted August 15, 2008 What I'm tring to do is check to see if the text file already has a line writen as the first line. if it is not there then write it, but if it is skip writting it. Func _write() $start = 0 $file3 = FileOpen(@ScriptDir & "\Database\" & "Database.txt", 9) $check = FileReadLine($file3, 1) If $check = "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors" Then $start = 1 EndIf If $start = 1 Then FileWriteLine($file3, "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors") EndIf FileWriteLine($file3, @MDAY & @MON & @YEAR & "," & $customer_inputr & "," & $quotenumber_inputr & "," & $qty_inputr & "," & $cost_inputr & "," & $xx & "," & $xx_me & "," & $margin_inputr & "," & $xx_m & "," & $xx_t & "," & $xx_s & "," & $b_descripr & "," & $colors_fr & "/" & $colors_br) FileClose($file) EndFunc Need a website: http://www.iconixmarketing.com
Andreik Posted August 15, 2008 Posted August 15, 2008 What I'm tring to do is check to see if the text file already has a line writen as the first line. if it is not there then write it, but if it is skip writting it. Func _write() $start = 0 $file3 = FileOpen(@ScriptDir & "\Database\" & "Database.txt", 9) $check = FileReadLine($file3, 1) If $check = "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors" Then $start = 1 EndIf If $start = 1 Then FileWriteLine($file3, "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors") EndIf FileWriteLine($file3, @MDAY & @MON & @YEAR & "," & $customer_inputr & "," & $quotenumber_inputr & "," & $qty_inputr & "," & $cost_inputr & "," & $xx & "," & $xx_me & "," & $margin_inputr & "," & $xx_m & "," & $xx_t & "," & $xx_s & "," & $b_descripr & "," & $colors_fr & "/" & $colors_br) FileClose($file) EndFunc I don't understand one thing, how you can read and write a file in same time?
dbzfanatic Posted August 15, 2008 Posted August 15, 2008 (edited) Func _write() $start = 0 $file3 = FileOpen(@ScriptDir & "\Database\" & "Database.txt", 9) $check = FileReadLine($file3, 1) If $check = "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors" Then $start = 1 EndIf If $start = 1 Then FileWriteLine($file3, "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors") EndIf FileWriteLine($file3, @MDAY & @MON & @YEAR & "," & $customer_inputr & "," & $quotenumber_inputr & "," & $qty_inputr & "," & $cost_inputr & "," & $xx & "," & $xx_me & "," & $margin_inputr & "," & $xx_m & "," & $xx_t & "," & $xx_s & "," & $b_descripr & "," & $colors_fr & "/" & $colors_br) FileClose($file) EndFunc From the looks of it you're telling the program that if the line IS there to write it again. Try Func _write() $start = 0 $file3 = FileOpen(@ScriptDir & "\Database\" & "Database.txt", 9) $check = FileReadLine($file3, 1) If $check = "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors" Then $start = 1 EndIf If $start = 0 Then FileWriteLine($file3, "Date,Customer,Quote #,Quantity,Cost,Price,Each,Margin,Profit,Tax,Price w/ tax,Description,Colors") EndIf FileWriteLine($file3, @MDAY & @MON & @YEAR & "," & $customer_inputr & "," & $quotenumber_inputr & "," & $qty_inputr & "," & $cost_inputr & "," & $xx & "," & $xx_me & "," & $margin_inputr & "," & $xx_m & "," & $xx_t & "," & $xx_s & "," & $b_descripr & "," & $colors_fr & "/" & $colors_br) FileClose($file) EndFunc Edited August 15, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote]
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now