Bharat
Bharat

Reputation: 177

How to validate a file input path? - PROGRESS 4GL

Below query helps to validate when I keep invalid path. The problem is its failing when I enter " \ " or "." or any special characters. How to validate them?

FILE-INFO:FILENAME = "\".

IF FILE-INFO:FULL-PATHNAME = "?" THEN
  MESSAGE "Invalid path".

Upvotes: 0

Views: 696

Answers (1)

Tom Bascom
Tom Bascom

Reputation: 14020

The "\" is an "escape" character on UNIX so that could certainly be a problem. Either double-escape it as "\\" or alternate-escape it with "~".

Mike's point about ? vs "?" is also spot-on.

In other words:

FILE-INFO:FILENAME = "~\".

IF FILE-INFO:FULL-PATHNAME = ? THEN
  MESSAGE "Invalid path".

Also - for portability reasons it is better to use forward slashes as directory separators. They work for either Windows or UNIX whereas backslash will only work if your code runs on Windows.

Upvotes: 3

Related Questions