jEdit Community - Resources for users of the jEdit Text Editor
How do I determine whether a file exists?
Submitted by PaulCollingwood on Thursday, 17 April, 2008 - 15:43
I'd like to write a macro for jEdit which runs an external application, and in doing this I wish to check whether a file at a specified path exists, and conditionally execute macro content on this basis.

Does anyone know how this is achieved?

Thanks in advance!
Comment viewing options
Select your preferred way to display the comments and click 'Save settings' to activate your changes.
oFile = new File(sP
by drefty on Thu, 17/04/2008 - 16:25
oFile = new File(sPath);
if(oFile.exists()){
oBuffer = jEdit.openFile(view, sPath);
Macros.message(view, oBuffer.toString());
}else{
view.getToolkit().beep();
}

Take a look at this link for an example script:
www.rutherfurd.net/jedit/macros/Compare_Buffer_Backups.bsh
 
Thanks drefty - this has prov
by PaulCollingwood on Fri, 18/04/2008 - 13:20
Thanks drefty - this has proved useful!

I'm a bit out of my comfort zone here, so apologize for my lack of knowledge....

Do you know where I can find a web-based API reference for objects such as 'File'? Is it part of some conventional Java object?

Thanks!
 
Hi Paul, Yes, File is par
by elberry on Mon, 21/04/2008 - 06:39
Hi Paul,
Yes, File is part of standard Java, or the Java Platform Standard Edition (Java SE).

You can find the JavaDocs here:
http://java.sun.com/javase/6/docs/api/

Here's a link specifically to the File class:
http://java.sun.com/javase/6/docs/api/java/io/File.html

If you're a programmer, most of that should make sense. If you're not, mainly focus on the "Method Summary". You can use any of those methods after you have a File object.

Hope that helps.

Learn from the past. Live in the present. Plan for the future.
11101000
 
If you look on the links spri
by drefty on Sat, 19/04/2008 - 15:07
If you look on the links sprinkled on community.jedit.org you will see one that points to the jEdit 4.2 API. This has extensive documentation on the internals of jEdit. If you are not familiar with Java programming, however, this may look pretty daunting.

Some might say it takes a bit of effort just to learn how to read and get used to the API docs.

An alternate approach would be to simply find jEdit macros wherever you can and read the source code for ideas, or search on a website such as Google Code Search. If you are really fortunate, some human being near you knows jEdit and is willing to help you learn these aspects with live person-to-person help.
User login
Browse archives
« April 2024  
MoTuWeThFrSaSu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
Poll
Are you interested in language packs for jEdit?
Yes, and I could help maintain translations
26%
Yes, I'd like to have translations
32%
Indifferent
35%
No, that'd be bad (please comment)
7%
Total votes: 1093
Syndication
file   ver   dls
German Localization light   4.4.2.1   82348
Context Free Art (*.cfdg)   0.31   46055
JBuilder scheme   .001   18495
BBEdit scheme   1.0   18116
ColdFusion scheme   1.0   18024
R Edit Mode - extensive version   0.1   17473
Advanced HTML edit mode   1.0   16206
Matlab Edit Mode   1.0   16068
jEdit XP icons   1.0   15229
XP icons for jEdit   1.1   14293