Get_Resource_Type Command
See Also: Direct_Input, Set_Resource_Library, Include_Resource, Get_Resource_Name, Register_Resource, Total_Resources
Purpose
To determine the type of a resource in the current resource library.
Note
This command is a character-mode legacy command that handles embedding of files as resources. This command does not work on embedded resources like bitmaps, icons, and version information that is compiled into a DataFlex application. See Resources for embedding these types of resources.
Syntax
get_Resource_Type resource to resource_type
Argument Explanation
- resource: The name of a resource or an integer equal to a valid resource ID.
- resource_type: An integer variable into which the name of the resource type is returned.
What It Does
Get_Resource_Type allows you to determine the type of a resource specified when the resource was embedded into the program during compilation. The resource_type can be any integer value. Zero and all negative values are reserved for predefined resource types; you may use all positive values for user-defined resource types. The predefined resource types are:
DF_RESOURCE_TYPE_BINARY: for resources in binary (undelimited) format.DF_RESOURCE_TYPE_LINE: for line-delimited resources.DF_RESOURCE_TYPE_ERROR: for invalid or uninitialized resources.
Resources defined as images use DF_RESOURCE_TYPE_LINE.
Resources included with the Include_Resource command default to DF_RESOURCE_TYPE_BINARY, but this may be overridden with the type command option (see the Include_Resource command).
If a resource is registered but never defined or included, it will have a resource type of DF_RESOURCE_TYPE_ERROR.
Example
integer iResType
string sLine 80
include_resource letter.txt as letter type DF_RESOURCE_TYPE_LINE
direct_input "resource: letter"
get_resource_type letter to iResType
if (iResType = DF_RESOURCE_TYPE_LINE) begin
// process line-delimited file
readln sLine
showln sLine
end
else if (iResType = DF_RESOURCE_TYPE_BINARY) begin
// process binary file
read_block sLine 80
showln sLine
end
else if (iResType = DF_RESOURCE_TYPE_ERROR) begin
showln "Resource 'letter' has not been initialized"
end
This simple example declares a resource, letter, then prints the first line to the screen. The if...else block handles the resource depending on its type.