NetTalk Central

Author Topic: File handling  (Read 3407 times)

Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
File handling
« on: June 03, 2014, 12:17:02 AM »
Hi

Have read threads about how to OPEN files (p_web.openfile() or relate:file.open()) and that seems clear enough but when do you have to OPEN files?

In a Form if you have client side code on field input or button push that has to read a file is it necessary to OPEN the file before processing? Well, I have 'til now assumed that you had to and have added the appropriate code and this has worked but on thinking about it I took the OPEN (and CLOSE) out and ran again and the code worked, so now I'm confused - it looks as if the file is OPEN but how did it get to be OPEN in this case?

I have a possibly peculiar setup which I had better explain in case its relevant:  In my Scenarios file I have some example records and after selecting one of these in the Browse the Form opens but it has no SAVE, INSET or any standard buttons.  All the user can do with the example is modify it and they can push a 'Save As' button which causes a record to be Inserted into the file that has the example values plus any modifications that have been made.

This is the setup I am referring to above where code seems to work without my explicitly OPENing files.

So,I guess it comes down to this:

  • for my Form do I ever have to OPEN files
  • for a standard Form is OPENing required under any circumstance
  • for a Source procedure, is OPENing required?
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File handling
« Reply #1 on: June 03, 2014, 04:10:44 AM »
>> In a Form if you have client side code on field input or button push that has to read a file is it necessary to OPEN the file before processing?

yes.

>> I took the OPEN (and CLOSE) out and ran again and the code worked, so now I'm confused - it looks as if the file is OPEN but how did it get to be OPEN in this case?

One would have to read the code to be sure. You can always use the STATUS clarion command to find out if a table is open or not. There are lots of things that may cause a table to be opened - but you should not assume it is open (unless you have looked at the code in context, and you can see it being opened.)

>>     for my Form do I ever have to OPEN files

yes - you should always open them if using them in hand-code.

>>     for a standard Form is OPENing required under any circumstance

indeed yes.

>>    for a Source procedure, is OPENing required?

again - look at the generated code and see. When in doubt always open the table yourself.

Cheers
Bruce


Keith

  • Sr. Member
  • ****
  • Posts: 306
    • View Profile
    • Email
Re: File handling
« Reply #2 on: June 03, 2014, 01:14:40 PM »
Thanks Bruce, that's clear now.

Another question - I am looking for an intermittent bug which posts an error message on the server:

'Entry not found [30] attempting to access a record from the Accelera file.'

The explanation for this is:

'A GET to QUEUE has failed. For GET(Q,key), the matching key value was not found, and for GET(Q,pointer), the pointer is out of range'

This is odd because 'Accelera' (actually Acceleration) is a Memory file (IMDD) and I don't have anywhere in this application the commands GET from a Queue by Pointer or Key.  But assuming that the error is really related to this file I do have a question about concurrent processing of the file which maybe could cause an error.

I use Acceleration to store data based on Session Id.  To make sure that the file size is kept to a minimum, whenever I add records I first delete the existing records for that session viz:

   LOOP until Access:Acceleration.next()
        if ACC:SessionId not= UserSessionId then break.
        Access:Acceleration.DeleteRecord(0)
   END

The file is Threaded.  Is it possible that if two or more sessions are concurrently reading and deleting records that an access error could result because of the timing of events - is this code 'safe' in an NT application?

Thanks

Keith
Clarion 10.0.0 build 12799
NetTalk 9.31
StringTheory 2.65
InsightGraphing 2.27

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: File handling
« Reply #3 on: June 03, 2014, 11:56:49 PM »
post new questions in a new thread - then I can answer it there....

cheers
Bruce