VS:ImportResToCurFileN: Difference between revisions

From Vectorworks Developer
Jump to navigation Jump to search
m (1 revision)
No edit summary
Line 1: Line 1:
{{LocationMain|category=LocationVS|specific=}}
 
__TOC__
__TOC__
<vwDoc>
<vwDoc>
Line 5: Line 5:
-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<desc>
<desc>
Imports the indicated resource from the specified list to the current file, if it is not already in the current file, and returns the handle to the resource.
Imports the indicated resource from the specified list to the current file, if it is not already in the current file, and returns the handle to the resource. It will use a callback function to determine how to handle duplicate resouce.</desc>
 
This function is similar to [[VS:ImportResourceToCurrentFile]] but it will not show a dialog when there is a conflict during the import.
</desc>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<def>
<def>
<funcDef lang="vs">
<funcDef lang="vs">
FUNCTION ImportResToCurFileN(listID: LONGINT; index: LONGINT; callback: FUNCTION) : HANDLE;;
FUNCTION ImportResToCurFileN(listID:LONGINT; index:LONGINT; callback:PROCEDURE) : HANDLE;
</funcDef>
</funcDef>
<funcDef lang="py">
<funcDef lang="py">
Line 24: Line 21:
<params>
<params>
<lineList ident=1>
<lineList ident=1>
<line>
type
INTEGER
the type of resource to put in the list
</line>
<line>
<line>
listID
listID
LONGINT
LONGINT
an ID for a resource list created by the [[VS:BuildResourceList]] or [[VS:BuildResourceListN]] command
 
</line>
</line>
<line>
<line>
index
index
LONGINT
LONGINT
an index into the list.
 
</line>
</line>
<line>
<line>
callback
callback
FUNCTION
PROCEDURE
a callback function used to resolve conflicts silently.
 
</line>
</line>
</lineList>
</lineList>
Line 48: Line 40:


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<remark>
<remark></remark>
The call back function will be called for a resource that cannot be imported due to a name conflict. The callback function should have the following definition:
<code lang="vs">
FUNCTION ImportResourceCallback(VAR resourceName:DYNARRAY OF CHAR) : INTEGER;
</code>
The 'resourceName' parameter contains the name of the conflict resource. The user might change the value in order to rename the imported resource.
The return value will tell Vectorworks how to resolve the conflict. The following values are defined:
* 0 - Do Not Import -- the conflict resource will be skipped during import.
* 1 - Replace -- the conflict resource will replace the existing in the document.
* 2 - Rename -- the conflict resource will be imported under the new 'resourceName' parameter value. If there is still conflict the callback function will be called again with the new name.
</remark>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<sample>
<sample></sample>
<code lang="vs">
{ try this on a file with some symbol folders }
PROCEDURE testResCountSymFolders;
VAR
    resList : LONGINT;
    numRes : INTEGER;
    h : HANDLE;
 
FUNCTION ImportResCallback(VAR resourceName:DYNARRAY OF CHAR) : INTEGER;
BEGIN
AlrtDialog( resourceName );
resourceName := Concat( resourceName , '-1' );
ImportResCallback := 2;
END;
 
BEGIN
    { list symbol folders in curr doc }
    resList := BuildResourceList(16, 23, '', numRes );
    h := ImportResToCurFileN( resList , 1, ImportResCallback );
    alrtDialog(concat('numRes=', numRes , ' h=', h));
END;
RUN(testResCountSymFolders);
</code>
</sample>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<seeAlso>
<seeAlso></seeAlso>
VS Functions:
[[VS:ImportResourceToCurrentFile]] | [[VS:BuildResourceList]] |[[VS:BuildResourceListN]]
</seeAlso>


-----------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------
<version>
<version>
Availability: from Vectorworks 2012
Availability: from Vectorworks 2014


</version>
</version>

Revision as of 17:36, 18 September 2013

Description

Imports the indicated resource from the specified list to the current file, if it is not already in the current file, and returns the handle to the resource. It will use a callback function to determine how to handle duplicate resouce.

FUNCTION ImportResToCurFileN(
listID :LONGINT;
index :LONGINT;
callback :PROCEDURE) : HANDLE;
def vs.ImportResToCurFileN(listID, index, callback):
    return HANDLE

Parameters

listID LONGINT
index LONGINT
callback PROCEDURE

Version

Availability: from Vectorworks 2014