Quick question about xxx::USED 
Author Message
 Quick question about xxx::USED


                       - - - - - - - - - -            

     I've noticed that practically every procedure starts with something
     like:

       IF filename::Used = 0
         CheckOpen(filename,1)
       END
       BIND(filename:RECORD)
       filename::Used += 1

     I put a MESSAGE statement in my code, and opened 3 or 4 procedures
     that all needed the same file, but the filename::USED variable never
     went over 1.  

     Can someone explain to me how this is supposed to work? (And maybe
     what CheckOpen does - I can't find it in the HELP.)

     Thanks.



Tue, 25 Jan 2000 03:00:00 GMT  
 Quick question about xxx::USED


                       - - - - - - - - - -            

Hi Robert

Believe you are talking about Intelligent File opening .. basically
if the file has not been opened the filename::Used is at zero .. once
CheckOpen opens the file in the proper mode the ::Used flag is set on
(to 1).

hth

Quote:
>      I've noticed that practically every procedure starts with something
>      like:

>        IF filename::Used = 0
>          CheckOpen(filename,1)
>        END
>        BIND(filename:RECORD)
>        filename::Used += 1

>      I put a MESSAGE statement in my code, and opened 3 or 4 procedures
>      that all needed the same file, but the filename::USED variable never
>      went over 1.  

>      Can someone explain to me how this is supposed to work? (And maybe
>      what CheckOpen does - I can't find it in the HELP.)

Best Regards
sm
----------------------------------------------------------------------------------------------
Steve MacLeod, Microcomputer Specialist          Computer Centre
University College of Cape Breton                Phone (902)563-1625
Sydney, N.S. Canada B1P 6L2                      Fax   (902)562-0119

Disclaimer: Any opinions expressed are mine alone, not a
reflection of any policy or position of UCCB.



Tue, 25 Jan 2000 03:00:00 GMT  
 Quick question about xxx::USED


                       - - - - - - - - - -            
Hi Robert,


Quote:
>     I've noticed that practically every procedure starts with something
>     like:

>       IF filename::Used = 0
>         CheckOpen(filename,1)
>       END
>       BIND(filename:RECORD)
>       filename::Used += 1

>     I put a MESSAGE statement in my code, and opened 3 or 4 procedures
>     that all needed the same file, but the filename::USED variable never
>     went over 1.  

If you check the generated code for the main source module
(appname.clw) you will find all the files declarations.  At the end of
each file, there is a variable declaration, something like:

Filename::Used  LONG,THREAD

The thread attribute means the variable is threaded and only change
within a thread.  So if you open 4 threads that open the same file,
this variable will show 1 in each one.  This variable is used to
control if a file is open or not.  

Quote:
>       IF filename::Used = 0
>         CheckOpen(filename,1)
>       END

Means, that if the file hasn't been opened (used) in this thread it
will be opened (Checkopen)  If you take a look at the ProcedureReturn
routine in the generated code for any procedure that opens files, you
will see that it checks if the file is used and if so, it closes the
file and reduces FileName::Used by one:

  IF FilesOpened
    Filename::Used -= 1
    IF Filename::Used = 0 THEN CLOSE(MyFile).
  END

Quote:
>     Can someone explain to me how this is supposed to work? (And maybe
>     what CheckOpen does - I can't find it in the HELP.)

It basically works so that if the file is open in the thread, no
attempt is made to open it.  At the end of the procedure a check is
made to see if the file should be closed (used = 0) and then it's
closed.  

CheckOpen is a generated function, found in the <appname>_SF.CLW
generated file (SF=Standard Functions)  It's basically the same as the
Open built in function, but has some error warnings etc. built in.
Take a look at the generated code to see how it's built:)

Best regards,

Arnor Baldvinsson
Allerup Edb
Tel: +45 4675 7122
Fax: +45 4675 7144
Denmark


http://www.icetips.com
UIN nr.: 2428601



Wed, 26 Jan 2000 03:00:00 GMT  
 Quick question about xxx::USED

On 8 Aug 1997 23:04:46 -0400, "ROBERT_MESSERLY%pcs

Quote:

>     I put a MESSAGE statement in my code, and opened 3 or 4 procedures
>     that all needed the same file, but the filename::USED variable never
>     went over 1.  

>     Can someone explain to me how this is supposed to work? (And maybe
>     what CheckOpen does - I can't find it in the HELP.)

The filename::Used is used globally to know when to 'close' the file.
If it was opened in a browse for example, it would be 1, then if you
call the update form, it would be 2.  Then when you close, the update
form checks for the USED variable, and if it is > 1, it does not close
the file (would ruin the browse it returns to) but it does 'decrement'
the variable, so it is 1 again when you return to the browse.  When
you close the browse it is still 1, so the browse procedure will
actually close the file.

Checkopen is a supplied function that handles the 'Open' parameters
you set up in the global properties, and dictionary.  Shared vs open,
default access etc...

HTH
George Cobaugh
TopSpeed Consulting and Education



Wed, 26 Jan 2000 03:00:00 GMT  
 Quick question about xxx::USED

Hello Robert!

Depending if you did open the same procedure 3 or 4 times, or you have 3 or
4 differents procedures using the same file, the filename::used will
display 1 if those procedure are separate threads.

The thread attribute on a var give to your procedure a new copy of this
var. This is why it displays 1 each time.



Quote:

>                        - - - - - - - - - -            

>      I've noticed that practically every procedure starts with something
>      like:

>        IF filename::Used = 0
>          CheckOpen(filename,1)
>        END
>        BIND(filename:RECORD)
>        filename::Used += 1

>      I put a MESSAGE statement in my code, and opened 3 or 4 procedures
>      that all needed the same file, but the filename::USED variable never
>      went over 1.  

>      Can someone explain to me how this is supposed to work? (And maybe
>      what CheckOpen does - I can't find it in the HELP.)

>      Thanks.



Wed, 26 Jan 2000 03:00:00 GMT  
 Quick question about xxx::USED


                       - - - - - - - - - -            

Quote:

>      I've noticed that practically every procedure starts with
> something
>      like:

>        IF filename::Used = 0
>          CheckOpen(filename,1)
>        END
>        BIND(filename:RECORD)
>        filename::Used += 1

>      I put a MESSAGE statement in my code, and opened 3 or 4
> procedures
>      that all needed the same file, but the filename::USED variable
> never
>      went over 1.

>      Can someone explain to me how this is supposed to work? (And
> maybe
>      what CheckOpen does - I can't find it in the HELP.)

>      Thanks.

  OK, the File::USED variable is just a quick way of stopping the
program unneccessarily trying to open a file. If a file is opened more
than once this is incremented instead so that  you can track if the file
is supposed to be closed or not.

I find it interesting that each message only comes up with 1. Are they
opened in different threads ??

CheckOpen: Checks to see if the file is open, if it's not it opens it
(in shared mode)

Tony Bowes
ECT(Int)
--

VR: The way TO the future  |  Brisbane, Australia.     (:)



Fri, 28 Jan 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Long ProductCode : xxx-xxx-xxx-xxx-999

2. Long ProductCode xxx-xxx-xxx-xxx-999

3. Quick questions on using regular expressino with gsub...

4. function to format $xxx,xxx.xx

5. XXX--Secret WEB CAMS at LADIES HOSTELS--XXX

6. Anyone using the Quick DDE template?

7. Quick tutorial on using the unicodedata module?

8. Quick, easy newbie question

9. Quick find replace question

10. Quick Question...

11. Quick listbox question

12. Quick Question

 

 
Powered by phpBB® Forum Software