- Subject: Dynamic string arrays in slang/jed?
- From: Brian Blais <bblais@xxxxxxxxxx>
- Date: Wed, 18 Feb 2004 11:10:57 -0500 (EST)
Hello,
I'm new to this list, and to jed, but I searched the archives and the
documentation and haven't found the answer to it. Hopefully I am not asking
something that has been hashed over before.
I am trying to make a string array which doesn't have a specified size at the
beginning. For example, getting a list of all of the images in a directory,
but I don't know how big the directory is. I made a function isimage() which
takes a string, and returns a true or false. I then go through a directory
listing, and want to add to my string array everytime I find an image.
Something like (which is not proper syntax):
fnames=[fnames; newstring]; % to add an element to the fnames string
My current solution is to use a jed buffer, copy the buffer, and then do a
strtok() call looking for end-of-line characters:
dirname="/home/blah/tmp";
s=listdir(dirname);
for (i=0; i<length(s); i++) {
if (isimage(s[i])) {
insert(dirname+"/"+s[i]+"\n");
}
}
bob();
push_mark();
eob();
fnames=bufsubstr();
fnames=strtok(fnames,"\n");
Is there a better solution? There are other applications that I would like
this functionality for, that don't involve directory listings, so a general
way to increase the size of an existing string array would be great.
thanks,
Brian Blais
-----------------
bblais@xxxxxxxxxx
web.bryant.edu/~bblais
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2004 date index]
[2004 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]