Jump to content
Developer Wiki and Function Reference Links ×

One resource list from 2 different sources


Recommended Posts

I have 2 sources, folders with different paths, for symbols I want to list in a drop down of a PIO.  I want to then select the symbol chosen from the list and import it into the document.

All of the various BuildResourceList functions will build a list from a specified folder, but I would like to build a resource list from 2 different folders.  I could make an array to hold the names from 2 different lists and display them, but I don't have a way to then specify the chosen symbol to be imported into the document.

Is there a way to make one resource list from 2 different sources, such that a subsequent ImportResource function will go to the correct place and import the correct symbol?

It might be possible to create a structure that holds the name of the symbol and indicator of which list to query, but I would really like to avoid that if I can.

 

As always, TIA.

Link to comment

@Sam Jones ,

   There are a lot of "ResList_" calls that I've never used, so I don't know if you cay build One List to rule them all, but I will say that the way you don't want to go really isn't that hard to implement, and once built, it stays perfectly registered between Symbol Name and Source List. Also, extending this approach to handle several lists would be quite easy.

 

   Here's a very quick sketch of how it could look. Of course, it's not tested. I wouldn't want to deprive you of all the fun.  😉   It assumes you won't have duplicate symbol names. Hopefully you don't, but if you do, one entry will point to list 1 and the other will point to list 2. If you want to specify your directories by absolute path, use BuildResourceListN() instead.

Type
	SymNameRec = Structure
		SName :Dynarray of Char;
		LID :Longint;
	end;		{ SymNameRec }
Var
	I, NumItems1, NumItems2 :Integer;
	ListID1, ListID2 :Longint;
	SymArray :Dynarray of SymNameRec;


BEGIN
	ListID1 := BuildResourceList(16, <folderIndexA>, <subFolderNameA>, NumItems1);
	ListID2 := BuildResourceList(16, <folderIndexB>, <subFolderNameB>, NumItems2);
	
	Allocate SymbolArray [1..NumItems1+NumItems2];
	
	for I := 1 to NumItems1 do begin
		SymArray[I].SName := GetActualNameFromResourceList(ListID1, I);
		SymbolArray[I].LID := ListID1;
	end;		{ for }
	
	for I := NumItems1+1 to NumItems1+NumItems2 do begin
		SymbolArray[I].SName := GetActualNameFromResourceList(ListID2, I);
		SymbolArray[I].LID := ListID2;
	end;		{ for }
	
	SortArray(SymArray, NumItems1+NumItems2, 1);
	
	...

HTH,

Raymond

 

Link to comment

I did, and it didn't.  There is the caveat that I did not rigorously investigate the failure.  I ended up as I thought I might creating 2 lists with separate BuildResource command and then making an array of a structure containing the resource name and a pointer to the list

LabelList = STRUCTURE

      Name : STRING;

      List : INTEGER; {1=my list, 2=user list}

END;

A little tedious to use, but it has the advantage of being able to be sorted with the compiled VS command SortArray(), which has a much better algorithm and resulting speed than my simple bubble sort.

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...