Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Test for file existence (ooRexx)

355 views
Skip to first unread message

Jennifer Murphy

unread,
Aug 28, 2014, 8:33:44 PM8/28/14
to
In ooRexx, what's the best way to test whether a file exists?

I found the Query Exists command of the Stream function,

result=stream(fid,"c","query exists")

It seems to do the job, but the description leaves me wondering if it's
the bext choice.

In Quercus Rexx, I've been using DOSDir(). I don't see a good ooRexx
replacement for that function.

Jeremy Nicoll - news posts

unread,
Aug 28, 2014, 9:21:58 PM8/28/14
to
Look at the utility functions, listed in a separate chapter from the
standard rexx built-in functions, eg SysFileExists().

--
Jeremy C B Nicoll - my opinions are my own.

Email sent to my from-address will be deleted. Instead, please reply
to newsre...@wingsandbeaks.org.uk replacing "aaa" by "284".

LesK

unread,
Aug 28, 2014, 11:08:17 PM8/28/14
to
SysIsFile() or SysIsFileDirectory(), depending on your needs.

--

Les (Change Arabic to Roman to email me)

Jennifer Murphy

unread,
Aug 29, 2014, 1:54:45 AM8/29/14
to
On Fri, 29 Aug 2014 02:21:58 +0100, Jeremy Nicoll - news posts
<jn.nntp....@wingsandbeaks.org.uk> wrote:

>Jennifer Murphy <JenM...@jm.invalid> wrote:
>
>>In ooRexx, what's the best way to test whether a file exists?
>>
>>I found the Query Exists command of the Stream function,
>>
>> result=stream(fid,"c","query exists")
>>
>>It seems to do the job, but the description leaves me wondering if it's
>>the bext choice.
>>
>>In Quercus Rexx, I've been using DOSDir(). I don't see a good ooRexx
>>replacement for that function.
>
>Look at the utility functions, listed in a separate chapter from the
>standard rexx built-in functions, eg SysFileExists().

Thank you. I should have found that.

I see that there is a similar function: SysIsFile.

In trhe description for SysFileExists, it says: "Returns true if any
file system entity with the given name exists. In particular, this will
return true for both regular files and directories."

In any case, that statement is not present in the description for
SysIsFile. Based on a little testing, I fond that SysFileExists will
return "1" if it finds a directory, whereas SysIsFile does not.

Are there any other differences?

What other file system "entities" are there other than files and
directories?

Jennifer Murphy

unread,
Aug 29, 2014, 2:05:04 AM8/29/14
to
Thanks. It looks like SysFileExists is a combination of SysIsFile and
SysIsFileDirectory, right?

Why is it not named SysIsDirectory?

Swifty

unread,
Aug 29, 2014, 3:29:46 AM8/29/14
to
On 29/08/2014 06:54, Jennifer Murphy wrote:
> What other file system "entities" are there other than files and
> directories?

I can't give you a definitive links, but you have things like
hard/soft/symbolic links, for example.

I found this out to my cost when one of my programs (running on Linux)
came across an object which was neither file nor directory, and promptly
failed.

I tend never to code "This cannot happen", as I've learned that such
messages can only ever prove you wrong. I tend to use "This is very
unusual". :-)

Users are very cynical if you give them a "cannot happen", but a "most
unusual" tends to fill them with curiosity - they're on your side when
they report the problem.

--
Steve Swift
http://www.swiftys.org.uk/

Jennifer Murphy

unread,
Aug 29, 2014, 4:28:44 AM8/29/14
to
On Fri, 29 Aug 2014 08:29:46 +0100, Swifty <steve....@gmail.com>
wrote:

>On 29/08/2014 06:54, Jennifer Murphy wrote:
>> What other file system "entities" are there other than files and
>> directories?
>
>I can't give you a definitive links, but you have things like
>hard/soft/symbolic links, for example.

I just tested it with a shortcut. Both SysIsFile and SysFileExists
returned "0". I expected that from SysIsFile, but not from
SysFileExists. That looks like a bug to me.

Rony

unread,
Aug 29, 2014, 7:10:18 AM8/29/14
to
You may want to try out and test the ooRexx .File class as documented in the rexxref.pdf book.

Whatever behaviour, if you think it is a bug you should file an issue/open a ticket to report it.
Usually the developers either accept or turn bugs down with an explanation, why it is working as
designed. <http://sourceforge.net/p/oorexx/bugs/>

---rony

rcbu...@gmail.com

unread,
Aug 29, 2014, 10:57:20 AM8/29/14
to
Here's what I use in Regina Rexx on linux (erasing a file in this example):

if lines(o_fid)>0 then do /* erase file if it exists from earlier */
'rm 'o_fid
end

Jennifer Murphy

unread,
Aug 29, 2014, 1:35:49 PM8/29/14
to
On Fri, 29 Aug 2014 13:10:18 +0200, Rony <rony.fl...@wu-wien.ac.at>
wrote:
Well, I tried to file a bug report. When I tried to register, it
rejected all of my attempts to choose a username:

JenniferMurphy
JenniferMurphy1
JenniferMurphy2
JenniferMurphy3
JenniferMurphy9
Jennifer-Murphy
JMurphy
JMurphy1
JMurphy99
JMurph
JMurph1
JMurph123
GoToHell

I give up. They clearly do not want my feedback.

LesK

unread,
Aug 29, 2014, 9:11:16 PM8/29/14
to
You have to have a SourceForge userid first! It's got nothing to do with
ooRexx welcoming your help.

Once you have a SF userid, you'll be able to access *any* SF project,
including ooRexx.

LesK

unread,
Aug 29, 2014, 9:14:42 PM8/29/14
to
Perhaps other OS's have other kinds of directories? Of maybe some future
OS might need to know SysIsCloudDirectory()?

Jennifer Murphy

unread,
Aug 30, 2014, 2:42:59 AM8/30/14
to
That's what I was trying to do. I was at this URL:

https://sourceforge.net/user/registration

I tried it with both Firefox and IE and I did have cookies enabled.

It said it would accept "gfdgfdgfd" as a username.

Jennifer Murphy

unread,
Aug 30, 2014, 2:54:19 AM8/30/14
to
Then clutter up the name when and if that ever happens.

I also discovered that SysFileExists does not return True for *any* file
system entity. I tried it on a shortcut file. It returned a "0". I guess
a shortcut file is not a file system entity.

I've only been working on this conversion for a few hours and already I
have over a dozen errors in the manuals. Did anyone proofread them?

LesK

unread,
Aug 30, 2014, 3:30:20 AM8/30/14
to
I just went there with FF and Opera. The box for Username: tells me:

Only lowercase letters, numbers or dashes

Didn't you see that?

Jennifer Murphy

unread,
Aug 30, 2014, 10:21:32 AM8/30/14
to
On Sat, 30 Aug 2014 03:30:20 -0400, LesK <5mr...@tampabay.rr.com> wrote:

>>> You have to have a SourceForge userid first! It's got nothing to do with
>>> ooRexx welcoming your help.
>>>
>>> Once you have a SF userid, you'll be able to access *any* SF project,
>>> including ooRexx.
>>
>> That's what I was trying to do. I was at this URL:
>>
>> https://sourceforge.net/user/registration
>>
>> I tried it with both Firefox and IE and I did have cookies enabled.
>>
>> It said it would accept "gfdgfdgfd" as a username.
>>
>I just went there with FF and Opera. The box for Username: tells me:
>
> Only lowercase letters, numbers or dashes
>
>Didn't you see that?

&*%$#^&%*$ I'll be damned. I didn't read that carefully enough. Thanks
for pointing that out. Now the registration went through.

(sigh)

LesK

unread,
Aug 30, 2014, 11:31:41 AM8/30/14
to
Don't feel bad! I'm vision impaired and have *lots* of FF add-ons that
sometimes screw up a web page, so "Been there, done that" Welcome to the
club. :-)

David H. Durgee

unread,
Aug 30, 2014, 11:40:34 AM8/30/14
to
You are touching on an area that always annoys me. Whoever built that
web form did not take the time to design the input field to match their
requirements. They could easily have restricted that input field to
accept only the characters that are legal, in which case attempting to
enter an illegal character will simply be ignored. I encounter this
most often on merchant sites where, undocumented, they prompt for a
credit card number but don't bother to tell you they want it without any
spaces or dashes in it. All they would have to do is place a similar
input restriction to digits only to accomplish this without any
inconvenience to the user.

Dave

Jennifer Murphy

unread,
Aug 30, 2014, 3:10:33 PM8/30/14
to
On Sat, 30 Aug 2014 11:40:34 -0400, "David H. Durgee" <m...@privacy.net>
wrote:

>>>>> It said it would accept "gfdgfdgfd" as a username.
>>>>>
>>>> I just went there with FF and Opera. The box for Username: tells me:
>>>>
>>>> Only lowercase letters, numbers or dashes
>>>>
>>>> Didn't you see that?
>>>
>>> &*%$#^&%*$ I'll be damned. I didn't read that carefully enough. Thanks
>>> for pointing that out. Now the registration went through.
>>>
>>> (sigh)
>>>
>> Don't feel bad! I'm vision impaired and have *lots* of FF add-ons that
>> sometimes screw up a web page, so "Been there, done that" Welcome to the
>> club. :-)
>
>You are touching on an area that always annoys me. Whoever built that
>web form did not take the time to design the input field to match their
>requirements. They could easily have restricted that input field to
>accept only the characters that are legal, in which case attempting to
>enter an illegal character will simply be ignored. I encounter this
>most often on merchant sites where, undocumented, they prompt for a
>credit card number but don't bother to tell you they want it without any
>spaces or dashes in it. All they would have to do is place a similar
>input restriction to digits only to accomplish this without any
>inconvenience to the user.

That would be ideal. But they could at least tell me what the problem
is.

LesK

unread,
Aug 31, 2014, 4:04:33 AM8/31/14
to
Agreed! Open a problem ticket. I did a long time ago and got an answer:
next release. Don't even remember what the problem was.

Jeremy Nicoll - news posts

unread,
Aug 31, 2014, 8:31:45 PM8/31/14
to
Jennifer Murphy <JenM...@jm.invalid> wrote:

> I also discovered that SysFileExists does not return True for *any* file
> system entity.

It's always worked for me... Are you remembering to include the whole path
with the filename being tested, including the filename extension?

> I tried it on a shortcut file. It returned a "0". I guess a
> shortcut file is not a file system entity.

Are you aware that a shortcut (in Windows) is a file with a .lnk extension?

IIRC Windows Explorer / File Explorer does not by default show the ".lnk"
part even if you turn display of extensions on for normal files.

Swifty

unread,
Sep 1, 2014, 2:16:03 AM9/1/14
to
On 30/08/2014 08:30, LesK wrote:
> Only lowercase letters, numbers or dashes

If they're so keen on lower case letters, why don't they translate
Jennifer's input to lower case? I thought these computers were invented
to help us, not frustrate our obvious intentions.

I'm still raging at sites that won't accept my credit card number as
written on my credit card. They want ME to remove the spaces for them.
They must still be using x286 computers...

Of course, the sites that really enrage me are the ones that won't
accept the credit card number without the spaces, once I've
pre-emptively removed them, just to cosset their code!

Swifty

unread,
Sep 1, 2014, 2:26:02 AM9/1/14
to
On 30/08/2014 20:10, Jennifer Murphy wrote:
> But they could at least tell me what the problem is.

I think that falls under the heading of "Not wanting to bore you with
the details"...

I'm at the opposite end of this spectrum. I delight in giving the user
as much information as possible. I even have a twonk() function to throw
in a gratuitous insult when the problem is a user error. My code might
look like this:

Say 'No UPPER CASE LETTERS. Read the instructions, you' twonk('!')

This might result in:

No UPPER CASE LETTERS. Read the instructions, you egregious ass!

See http://www.swiftys.org.uk/insult for the full panoply of my insults.
Additions gratefully received!

Swifty

unread,
Sep 1, 2014, 2:31:15 AM9/1/14
to
On 31/08/2014 09:04, LesK wrote:
> I did a long time ago and got an answer: next release.

I installed an app on my phone that triggers actions when I'm within a
given distance of a given location (or outside that distance).
They solicited suggestions, of which I had two:

1. When I go out the front door, intending to go shopping, it would
remind me to go back to fetch my wallet.
2. When I went into a different room in my house, it would remind me
why I went there.

An hour later I got the answer: Those are both in the next release.

Swifty

unread,
Sep 1, 2014, 2:34:41 AM9/1/14
to
On 29/08/2014 15:57, rcbu...@gmail.com wrote:
> if lines(o_fid)>0 then do /* erase file if it exists from earlier */
> 'rm 'o_fid

Do you worry about the fact that your code mightn't erase a null file?

Blue Bullet

unread,
Sep 1, 2014, 6:28:31 PM9/1/14
to
No, should I? I prefer not to remove null files.

Swifty

unread,
Sep 2, 2014, 4:08:34 AM9/2/14
to
On 01/09/2014 23:28, Blue Bullet wrote:
> No, should I? I prefer not to remove null files.

Then all is well.

I've been involved in IT for about 48 years, so it is second nature for
me to spot unusual circumstances that just might not produce the desired
outcome.

Unfortunately, a side effect is that I'm almost impossible to live with.
Fortunately, my wife was involved in IT for almost the same time, so
we're OK.

Blue Bullet

unread,
Sep 2, 2014, 5:34:18 PM9/2/14
to
Thanks for the clarification. I have been at it since the early 70's and understand what you are saying. In many cases it is not a question of being hard to live with; we simply are ignored. Sometimes for good reason.

When riding the trails it is best to leave Gates the way you find them.
If closed, open it, pass thru and close it. If open, pass thru and leave it open. The same often applies to IT.

I no longer do Windows (pun intended).

Shmuel Metz

unread,
Sep 4, 2014, 10:56:47 AM9/4/14
to
In <lu12uv$n4m$1...@speranza.aioe.org>, on 09/01/2014
at 07:15 AM, Swifty <steve....@gmail.com> said:

>Of course, the sites that really enrage me are the ones that won't
>accept the credit card number without the spaces, once I've
>pre-emptively removed them, just to cosset their code!

How about the sites that "validate" your e-mail address, incorrectly?

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to spam...@library.lspace.org

Swifty

unread,
Sep 7, 2014, 2:26:27 AM9/7/14
to
On 02/09/2014 22:34, Blue Bullet wrote:
> When riding the trails it is best to leave Gates the way you find them.

I was taught this at the age of 11, when I became the breadman's
delivery assistant for a few weeks in the summer.

At my very first customer, Maurice (BreadMan) shouted at me for leaving
the gate open.

So, at customer #2 I carefully closed the gate. Maurice explained: If
they'd left the gate open, they probably like it that way, so leave it
as you find it.

But don't you find yourself agonising over a gate you found open, when
it looks as though it should be shut? (and was probably left open by
some oaf passing through previously)

Blue Bullet

unread,
Sep 7, 2014, 12:21:08 PM9/7/14
to
On Sunday, September 7, 2014 12:26:27 AM UTC-6, Swifty wrote:
> On 02/09/2014 22:34, Blue Bullet wrote:
>
> > When riding the trails it is best to leave Gates the way you find them.
>
>
> But don't you find yourself agonising over a gate you found open, when
>
> it looks as though it should be shut? (and was probably left open by
>
> some oaf passing through previously)
>
>
>
> --
>
> Steve Swift
>
> http://www.swiftys.org.uk/
Only if I see stock on one side of the fence. If they are on both sides, it is too late. If I see stock on one side only, I will close it, and if I see someone down the way, I will tell them I did it and why.
0 new messages