Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 1187

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Using Web Elements and External Objects
structure. --->
<cfset drives=Application.fso.drives()>
<cfset driveSpace=StructNew()>
<cfloop collection="#drives#" item="curDrive">
<!--- A DriveType of 2 indicates a fixed disk --->
<cfif curDrive.DriveType IS 2>
<!--- Use dynamic array notation with the drive letter for the struct key
--->
<cfset driveSpace["#curDrive.DriveLetter#"]=curDrive.availablespace>
</cfif>
</cfloop>
<cfreturn driveSpace>
</cffunction>
<!--- Test the function. Get the execution time for running the function --->
<cfset start = getTickCount()>
<cfset DriveInfo=getFixedDriveSpace()>
<h3>Getting fixed drive available space</h3>
<cfoutput>Execution Time: #int(getTickCount()-start)# milliseconds</cfoutput><br><br>
<cfdump label="Drive Free Space" var="#driveInfo#">
Example 2: Using the Microsoft Word application object
The following example uses the Microsoft Word application COM object in the Application scope to convert a Word
document to HTML. This example works with Word 2000 as written. To work with Word 97, change "Val(8)" to
"Val(10)".
This example uses an Application scope lock to ensure that no other page interrupts creating the object. Once the
Word object exists, the example uses a named lock to prevent simultaneous access to the file that is being converted.
<cfapplication name="comtest" clientmanagement="No" Sessionmanagement="yes">
<!--- Uncomment the following line if you must delete the object from the
Application scope --->
<!--- <cfset structdelete(Application, "MyWordObj")> --->
<!--- use the GetTickCount function to get a current time indicator, used for
displaying the total processing time. --->
<cfset start = GetTickCount()>
<!--- If necessary, create the Word.application object and place it in the
Application scope --->
<cfset WordObj_is_initialized = False>
<cflock scope="application" type="readonly" timeout=120>
<cfset WordObj_is_initialized = StructKeyExists(application, "MyWordObj")>
</cflock>
<cfif not WordObj_is_initialized >
<cflock scope="Application" type="exclusive" timeout="120">
<cfif not StructKeyExists(application, "MyWordObj")>
<!--- First try to connect to an existing Word object --->
<cftry>
<cfobject type="com"
action="connect"
class="Word.application"
name="Application.MyWordobj"
context="local">
<cfcatch>
<!--- No object exists, create one --->
Last updated 1/20/2012
1182

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents