Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Is a SCX open somewhere
Message
From
12/02/2009 17:56:07
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 7 SP1
Miscellaneous
Thread ID:
01381369
Message ID:
01381454
Views:
32
>How do I determine if a form is open for editing somewhere and then bypass my attempt to open the .SCX

TRY - CATCH - ENDTRY would be the best; but alas, it is not available in vers 7. You can use an ON ERROR handler but that could be cumbersome. I would try the following:
lcFilePath = GETDIR()
IF !EMPTY(lcFilePath)
  lcFilePath = ADDBS(lcFilePath)
  lnFileCnt = ADIR(laFiles,lcFilePath+"*.scx")
  FOR lnFile=1 TO lnFileCnt
    lcFile = lcFilePath + laFiles[lnFile,1]
    lhFile = FOPEN(lcFile,0)
    IF lhFile > 0
       =FCLOSE(lhFile)
       USE (lcFile) IN 0 ALIAS my_scx
    ELSE
      WAIT WINDOW "File in Use: " + lcFile
    ENDIF
  ENDFOR
ENDIF
The FOPEN command will not throw an exception if it cannot open the file -- the file handle returned of 0 indicates failure. Whereas, USE will cause an error.
Previous
Reply
Map
View

Click here to load this message in the networking platform