dbenum() & dbinfo()

Discuss PocketC for Palm OS (including Desktop Edition)

Postby cable_guy_67 on Sun Feb 22, 2004 3:59 pm

I was wondering if there is a better way to do this:

I would like to search for 'appl' type programs on a device that conform to a CID pattern. The pattern I am looking to find has 3 common characters with the last being different. For example:

cid 'Dex*' is the pattern I would like to match. Then I will add this to a launch list. Using dbenum(0,"appl","") and following the example dbenum.c from the samples directory I can list all the 'appl' type programs on the device. Is there any way to refine the wildcard search? I thought maybe dbenum(1, "appl", "Dex"+"") might be it but it is not.

The only other option I have come up with is to create an array of the filenames based on info in this post:

Where the filelist is created with dbenum(0,"appl","") then calling dbenum(1,"appl","") until it returns 0 storing the filenames and then calling dbinfo(filename,&filetype, &creator_id) then checking if the string stored by &creator_id conforms to my pattern.

Any thoughts on this would be appreciated.

Posts: 92
Joined: Mon Mar 31, 2003 2:28 am
Location: USA

Postby dewey on Mon Feb 23, 2004 4:36 am

That is the correct approach. As an optimization, you can do the filtering while enumerating, so that you only store the database names that match, rather than all of them.
Site Admin
Posts: 749
Joined: Sun Oct 21, 2007 5:12 am

Postby cable_guy_67 on Mon Feb 23, 2004 12:19 pm

Thanks Jeremy, I was hoping that there was an easier way to pattern match the cid but was not too hopeful. :D

If anyone is interested, this works for my purposes and is easily modified for similar checks.

Code: Select all
   string launch_file[5],launch_cid[5];
   string file_name, file_cid, file_type;
   int i;
   file_name = dbenum(1,"appl","");
         if(file_cid@[0]=='D') if(file_cid@[1]=='e') if(file_cid@[2]=='x'){
            launch_file[i] = file_name;
            launch_cid[i] = file_cid;
         if(i == 5){
      file_name = dbenum(0,"appl","");
   }while(file_name !=0);

This pulls all the 'appl' type files and then checks the first 3 characters of the CID to see if it matches my specific pattern. The same could be used to check file names or other file types to store for later launching from within PocketC.
Posts: 92
Joined: Mon Mar 31, 2003 2:28 am
Location: USA

Return to PocketC for Palm OS

Who is online

Users browsing this forum: No registered users and 8 guests