Difference between revisions of "Resource searchByName"

From Catglobe Wiki
Jump to: navigation, search
(Created page with "= Resource_searchByName = Search a resource by name. <br> === Syntax === Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, NameSearchType, Sear...")
 
 
(29 intermediate revisions by 5 users not shown)
Line 1: Line 1:
 
= Resource_searchByName  =
 
= Resource_searchByName  =
 +
[[Category:Resource_Functions]]
 +
__NOTOC__
 +
 +
Search resources by name.
 +
 +
=== <span style="color:#DF8621">'''Syntax'''</span> ===
 +
 +
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount);
  
Search a resource by name.
+
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId);
  
<br>
+
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId, includeSubChildren);
  
=== Syntax  ===
+
=== <span style="color:#DF8621">'''Arguments'''</span> ===
  
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, NameSearchType, SearchMaxCount)  
+
*ResourceName: is a string. It is the pattern of name of resource which user want to look up.
 +
*ResourceType: is a value of Resource type constants. Or we can also use the name of [[CGS Constants list|Resource type constants]].
 +
*ResourceTemplateResourceID: is a number. It is the resource id of resource template ID. This value can be set 0 if don't care which template to search for.
 +
*SearchType: is a number. It's the value of the Search type constants. Or we can aslo use the name of [[CGS Constants list|the Search type constants]].
 +
*SearchMaxCount: is a number. It's the number of resources we want this function return. default vaulue = 10, if set value to 0, it'll return all
 +
*ParentResourceId: is a number. It's resource id used to determine search resources in it
 +
*includeSubChildren: is a bool (the parameter is optional)
  
<br>
+
The SearchType constants list:
  
=== Arguments  ===
+
*NAME_SEARCH_TYPE_START
 +
*NAME_SEARCH_TYPE_END
 +
*NAME_SEARCH_TYPE_ANYWHERE
 +
*NAME_SEARCH_TYPE_IDENTICAL
  
ResourceID: is a number. It is the resource id of resource. ResourceName: is a string. It is a name of resource which user want to look up. ResourceType: It is a value of Resource type's constant. Or can be used a Name of "Resource Type" constant [[Resource Type|CGS_Constants_list]]. ResourceTemplateResourceID: is a number. It is the resource id of resource template ID. This value can be set 0 if don't care which template to search for. NameSearchType: It is a value of Name Search type's constant. Or can be used a name of "Name Search Type" constant [[Name Search Type|CGS_Constants_list]].. <br>
+
=== <span style="color:#DF8621;">'''Return type'''</span> ===
  
=== Return type  ===
+
An array of matched resources, which contain the information of resources that match the search pattern. <br>
  
An Array, which contain the information of resource was found. <br>
+
The matched resources will be represent by an array. Below is the constants list which explain the meaning of each element in this array:
  
=== Examples ===
+
*RESOURCE_RESOURCE_ID : Rid of resource
 +
*RESOURCE_NAME : Name of resource
 +
*RESOURCE_TYPE : Type of resource
 +
*RESOURCE_PARENT_RESOURCE_ID : Rid of parent resource
 +
*RESOURCE_TEMPLATE_RESOURCE_ID : Rid of resource template
  
string RName = "phong"; number RType = Resource_Type_Report; number RTempRID = 0; number NSType = 1; Number SMcount= 1;  
+
=== <span style="color:#DF8621;">'''Examples'''</span>  ===
 +
<source lang="javascript">
 +
string ResourceNamePattern = "phong";
 +
number ResourceType = 10; // or ResourceType = Resource_Type_Report;
 +
number ResourceTempRID = 0;
 +
number SearchType = 1; // or SearchType = NAME_SEARCH_TYPE_ANYWHERE;
  
array Result = Resource_searchByName(RName, RType, RTempRID, NSType); print(Result);  
+
Number SearchMaxcount= 3;
 +
array Result;
  
//{{10,37257205,Phong report 2,12,37246022,34409964},{10,37257212,Phong report 1,12,37246022,34409964},{10,37272405,phong report 3,12,37246022,34409964},{10,37272427,Phong report 4,12,37246022,34409964},{10,37272501,phong,12,37272491,34409964}} __NOTOC__
+
Result = Resource_searchByName(ResourceNamePattern, ResourceType, ResourceTempRID, SearchType);
 +
print(Result.Count);
 +
print(Result);
  
[[Category:Resource_Functions]]
+
// 5 resources were found
 +
//{{10,37257205,Phong report 2,12,37246022,34409964},{10,37257212,Phong report 1,12,37246022,34409964},{10,37272405,phong report 3,12,37246022,34409964},{10,37272427,Phong report 4,12,37246022,34409964},{10,37272501,phong,12,37272491,34409964}}
 +
 
 +
Result = Resource_searchByName(ResourceNamePattern, ResourceType, ResourceTempRID, SearchType, SearchMaxcount);
 +
print(Result.Count);
 +
print(Result);
 +
 
 +
// 3 resources were found
 +
//{{10,37257205,Phong report 2,12,37246022,34409964},{10,37257212,Phong report 1,12,37246022,34409964},{10,37272405,phong report 3,12,37246022,34409964}}
 +
 
 +
</source>
 +
 
 +
<source lang="javascript">
 +
//Example for using optional parameter: includeSubChildren
 +
 
 +
string ResourceName = "sub folder";
 +
number ResourceType = Resource_Type_Folder;
 +
number ResourceTemplateResourceID = 2071;
 +
number SearchType = NAME_SEARCH_TYPE_ANYWHERE;
 +
number SearchMaxCount = 0;
 +
number ParentResourceId = 15592993;
 +
Bool includeSubChildren = true;
 +
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId, includeSubChildren);
 +
//Result: {{10,15592994,sub folder 1,6,15592993,2071},{10,15592995,sub folder 1 1,6,15592994,2071}}
 +
 
 +
// if not set includeSubChildren or includeSubChildren = false:
 +
//Result: {{10,15592994,sub folder 1,6,15592993,2071}}
 +
</source>

Latest revision as of 11:16, 14 August 2017

Resource_searchByName


Search resources by name.

Syntax

Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount);

Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId);

Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId, includeSubChildren);

Arguments

  • ResourceName: is a string. It is the pattern of name of resource which user want to look up.
  • ResourceType: is a value of Resource type constants. Or we can also use the name of Resource type constants.
  • ResourceTemplateResourceID: is a number. It is the resource id of resource template ID. This value can be set 0 if don't care which template to search for.
  • SearchType: is a number. It's the value of the Search type constants. Or we can aslo use the name of the Search type constants.
  • SearchMaxCount: is a number. It's the number of resources we want this function return. default vaulue = 10, if set value to 0, it'll return all
  • ParentResourceId: is a number. It's resource id used to determine search resources in it
  • includeSubChildren: is a bool (the parameter is optional)

The SearchType constants list:

  • NAME_SEARCH_TYPE_START
  • NAME_SEARCH_TYPE_END
  • NAME_SEARCH_TYPE_ANYWHERE
  • NAME_SEARCH_TYPE_IDENTICAL

Return type

An array of matched resources, which contain the information of resources that match the search pattern.

The matched resources will be represent by an array. Below is the constants list which explain the meaning of each element in this array:

  • RESOURCE_RESOURCE_ID : Rid of resource
  • RESOURCE_NAME : Name of resource
  • RESOURCE_TYPE : Type of resource
  • RESOURCE_PARENT_RESOURCE_ID : Rid of parent resource
  • RESOURCE_TEMPLATE_RESOURCE_ID : Rid of resource template

Examples

string ResourceNamePattern = "phong";
number ResourceType = 10; // or ResourceType = Resource_Type_Report;
number ResourceTempRID = 0;
number SearchType = 1;  // or SearchType = NAME_SEARCH_TYPE_ANYWHERE;

Number SearchMaxcount= 3;
array Result;

Result = Resource_searchByName(ResourceNamePattern, ResourceType, ResourceTempRID, SearchType); 
print(Result.Count);
print(Result); 

// 5 resources were found
//{{10,37257205,Phong report 2,12,37246022,34409964},{10,37257212,Phong report 1,12,37246022,34409964},{10,37272405,phong report 3,12,37246022,34409964},{10,37272427,Phong report 4,12,37246022,34409964},{10,37272501,phong,12,37272491,34409964}}

Result = Resource_searchByName(ResourceNamePattern, ResourceType, ResourceTempRID, SearchType, SearchMaxcount); 
print(Result.Count);
print(Result); 

// 3 resources were found
//{{10,37257205,Phong report 2,12,37246022,34409964},{10,37257212,Phong report 1,12,37246022,34409964},{10,37272405,phong report 3,12,37246022,34409964}}
//Example for using optional parameter: includeSubChildren

string ResourceName = "sub folder";
number ResourceType = Resource_Type_Folder; 
number ResourceTemplateResourceID = 2071;
number SearchType = NAME_SEARCH_TYPE_ANYWHERE; 
number SearchMaxCount = 0;
number ParentResourceId	= 15592993;
Bool includeSubChildren = true;
Resource_searchByName(ResourceName, ResourceType, ResourceTemplateResourceID, SearchType, SearchMaxCount, ParentResourceId, includeSubChildren); 
//Result: {{10,15592994,sub folder 1,6,15592993,2071},{10,15592995,sub folder 1 1,6,15592994,2071}}

// if not set includeSubChildren or includeSubChildren = false: 
//Result: {{10,15592994,sub folder 1,6,15592993,2071}}