Files

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Files

Post by Andycal » Tue Feb 12, 2008 2:30 pm

OK, I'm grabbing a list of all files in a directory and popping them in a variable. I'm then going through each file and replacing some text in each one.

Now, I only want to do the above process on text files. Is there a way to *just* get all the files with a '.txt' extension?

Currently, I'm doing this:

Code: Select all

  put URL ("file:" & rWords) into kWords
Which just grabs everything.

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Post by BvG » Tue Feb 12, 2008 3:13 pm

You need to use the defaultfolder, together with the files for this:

Code: Select all

On mouseUp
  answer folder "a Folder"
  if it = "" or the result <> "" then
    exit mouseUp
  end if
  set the defaultfolder to it
  set the itemdelimiter to "."
  repeat for each file rWords in the files
    if item -1 of rWords = "txt" then
      put URL ("file:" & rWords) into kWords
      -- do stuff here with kWords
    end if
  end repeat
end mouseUp
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Tue Feb 12, 2008 6:03 pm

Fabulous.... I've got another question now...

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Finding *.txt files

Post by bjb007 » Wed Feb 13, 2008 10:43 am

Seems to me that it would be simpler to put all the names
into an array then delete the array elements which contain
the string ".txt" and process the rest.

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Feb 13, 2008 11:47 am

One could also:
...
put the files into tFiles
filter tFiles with "*.txt"
## Now tFiles will contain only TXT files :-)
...


Best

Klaus

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

You've obviously got this licked...

Post by bjb007 » Wed Feb 13, 2008 12:48 pm

I'm a believer in concise code so thanks for this
one Klaus.

As you might guess I'm just starting with Rev and
keep thinking of the "good old days" when
programming languages came with a dozen books
of info.

Even then the common complaint was that the info.
covered one topic without giving an example of doing
a project from start to finish.

What would you suggest is the best/quickest way
to find what I'm looking for? The info. seems to
be there but the problem is where is "there".

Have a copy of the 2.1.2 PDF but the information is
spread around in a haphazard way and it takes so
long to search all 3193 pages!

Klaus
Posts: 14193
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Wed Feb 13, 2008 12:55 pm

Hi bjb007,

I would suggest that you

1. work through all stack you canfind here:
http://support.runrev.com/scriptingconferences/

2. Then grab all stacks that you can get from "Revonline" and other websites that offer unprotected downloads, and dive into all their scripts.

At least for me this is the best way to learn Rev!


Best

Klaus

Andycal
Posts: 144
Joined: Mon Apr 10, 2006 3:04 pm

Post by Andycal » Wed Feb 13, 2008 2:00 pm

I find the best way to learn a programming language is to have something to do. I've had RunRev on my laptop for over a year, but it's only now I really had a use for it.

I looked at existing scripts to get most of what I needed and then asked questions here, eventually the structure, syntax and design of RunRev begins to bed in.

Now looking to enhance the programs I've written which in itself will teach me even more.

bjb007
Posts: 313
Joined: Fri Dec 28, 2007 4:56 am

Learning Rev

Post by bjb007 » Wed Feb 13, 2008 2:08 pm

Thanks for your replies Klaus and Andycal.

Perhaps my "problem" is that I became very
proficient with dBase and FoxPro in the '80s so
usually go looking for something that was
available in those languages.

So knowing what I want to do I need to find a
way of doing it and going through stacks takes
a lot of time and then I mightn't find what I want.

Can you or anyone else tell my why the Rev help file
isn't at all like the one in the videos? If I had that
I'd be away....

Wonder if anyone has thought of having a Wiki-style
Rev resource where users could add ideas and code
which would be easily searchable. A lot of the sites
I've visited which claim to be devoted to Rev have
very little of use to me and a lot of them have that
"abandoned" look.

Post Reply