I don’t envy you your crash course in Clarion, Kajee
A couple of suggestions when posting questions here:
Clarion has two development paradigms: “Legacy/Classic/Clarion” or “ABC”. When asking about coding or code “embeds” (and especially about data access) it’s really important to specify whether the app in question is ABC or Legacy.
Clarion works with a number of database backends. It’s a good idea to specify (Topspeed?, MS SQL?, postgres? … etc…)
As well as the other questions and comments people have asked, what do you mean by “if its the last records in the file, it fails , with a record not found”? You are not showing your delete logic - is it the delete that is failing or the read? Or perhaps the commit that is failing? The more detail you give the better. And show all your code. And say exactly where and how it is failing.
I normally would use errorcode() rather than error() but either should work OK. So when it reaches the end of file the code should break out of the loop. You should not get an error message.
Finally 20 is a large value for the logout timeout. Maybe two seconds is enough?
what do you mean by “if its the last records in the file, it fails , with a record not found”? For example if i had 5 sales orders, i was looping over the lines of sales order 5 which are last in the file according to the order no key, then it end of by filing ‘Record Not Available’ Apologies, it was Not Available and not ‘not found’
Will you logout the file once before the loop, or so you logout within the loop ? (His original code was deleted the sales order line in a loop while doing other processing) The change is to only delete the sales order lines after all processing is done. I have attached the entire module, you can see where i Commented out the original delete(SALES_ORDER_LINE) and below it where i trying my loop, with a MESSAGE(SALES_ORDER_LINE.ORDER_NO) cashsale010.clw (607.8 KB)
The LOGOUT in your code above might be a problem. In the cashsale010.clw on line 1073 is also a line with a LOGOUT statement and the corresponding COMMIT is on line 1436. But if your code including the LOGOUT/COMMIT pair is included on line 1430 that might be a problem. You cannot do two LOGOUT’s without committing the first.
You have IF ERROR()
in your code. It might be better to change that into IF ERRORCODE()
The code in your cashsale010.clw is not ABC but legacy. So I presume all your code will be legacy. Not that is makes much difference, but you will need solutions in legacy.
I would check, but that sounds normal. Just note that the error on NEXT() will NOT clear the file buffer, so the previous contents will still be there.
So double check to see if all your records are in fact deleted.
Thank you all, i have come right with this.
The issue was , to exit the loop , you break on the the end of file error. and after the loop i had an error catcher, which was catching that error.
I found one of my dads old books, he, its for clarion 5.5, Programmers Guide, it seems like a good starting point for me .
With a loop like that, if you are dealing with the last order in the file, you EXPECT to run into Record not found. For the records that are not at the end of the file, you expect to run into the next order number at some point. In both of those cases you just want to (I would expect) stop your looping process (i.e. BRAK) and return, rather than tell the user that something bad happened.
I assume you actually have something like:
if error() then
You can do something like
if errorcode() = 33 or sol:order_no != soh_order_no! record not available (end of file) or finished order
else if errorcode()
message('This is a real error ’ & error())
True, but you have also a Clarion 11 version available. Not as a hard copy as your 5.5 version but as a PDF file. You can find it in the directory “Doc” which is a sub directory in your Clarion install directory.