Jump to content
Developer Wiki and Function Reference Links ×

Resource Folder inside Resource Folder


Recommended Posts

The script below fails when the parent exists and when the parent cable does not exist.  It also fails using InsertSymbolInFolder().  Putting a BeginFolder inside a BeginFolder also fails.

 

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');
    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolder;
            EndFolder;
            FolderHdl := LNewObj;
        END;
    NameObject('Inside AP Cable Folder');
    BeginFolder;
    EndFolder;
    Folder2Hdl := GetObject('Inside AP Cable Folder');
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}

END;
RUN(PutFolderInFolder);
 

Link to comment

SetParent() does work for placing resources in folders, but as you observe it fails for symbols. I suspect this is due to somewhat simplistic error checking; you can't place a record in a symbol folder, only a record folder, etc. I'm guessing you are restricted from placing a folder in a folder via script. 

I would file this as a bug, and if it's WAD have it moved to an enhancement request.

Link to comment

I would expect nested BeginFolders to fail. The first folder would not yet exist when the nested one was trying to be created. 

 

LNewObj only works (as far as I know) on SOME objects that are actually visible in the drawing. I would not expect it to work on resources.

 

Check out CreateFolderN in the function reference.

 

Quote

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');

    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolderN(16);
                NameObject('Inside AP Cable Folder');
                BeginFolderN(16);
                EndFolder;
            EndFolder;
        End;

        AlrtDialog(Concat(FolderHdl,'  ',Folder2Hdl));
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}
END;
RUN(PutFolderInFolder);

 

Link to comment

It was in the quote in my post above. I had my window set to narrow and could not see the Code block icon and assumed that they had updated the forum and removed it.  Reposted here. This is a minor modification to your code that puts nested folders in for me.  

 

The 16 in the BeginFolderN specifies Symbol folders, but I think you can use most of the type codes for Definitions in the VS Appendix Object Type table that are listed as Definition.

PROCEDURE PutFolderInFolder;
VAR
    FolderName : STRING;
    FolderHdl : HANDLE;
    Folder2Hdl : HANDLE;
    ok : BOOLEAN;
    
BEGIN
    FolderHdl := GetObject('AP Cable Folder');
    IF FolderHdl = NIL THEN
        BEGIN
            NameObject('AP Cable Folder');
            BeginFolderN(16);
                NameObject('Inside AP Cable Folder');
                BeginFolderN(16);
                EndFolder;
            EndFolder;
        End;
        AlrtDialog(Concat(FolderHdl,'  ',Folder2Hdl));
    ok := SetParent(Folder2Hdl, FolderHdl);
    IF (NOT ok) THEN
        AlrtDialog('ok set parent is false');
    {InsertSymbolInFolder(FolderHdl, Folder2Hdl);}
END;
RUN(PutFolderInFolder);
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...