Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Checking if file exists

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Checking if file exists
 Login/Join
 
Guru
posted
Trying to check whether a file exists or not using the STATE command.

Have tried with

STATE filename
STATE app\filename
STATE app/filename
STATE approot\app\filename
STATE \\node\sharename\ibi\apps\directory\filename

All returns -1, despite the file actually exist.

We're on WF 5.2.7 on IBM iSeries (AS/400).
Clue anyone?

Tia,
Hakan
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
<Pietro De Santis>
posted
Here's some code I found that works:

-SET &FDATE = AYMD(&YYMD,-1,'I8');
-SET &FN2 = '/ibi/srv51/ffs/catalog/sa'|EDIT(&FDATE,'$$999999')|'.ftm' ;
STATE &FN2
-RUN
-IF &RETCODE EQ 0 GOTO CREATED ;
 
Report This Post
Master
posted Hide Post
Might be because your filename contains a blank or a dollar (don't know which).

Have to dos copy to a simple filename and then check that with STATE to get things to work.



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Master
posted Hide Post
Tom

STATE does not work if there's a blank in the filename. Try this:

-DOS ECHO HELLO > "HELLO WORLD.TXT"
-DOS TYPE "HELLO WORLD.TXT"
DOS STATE "HELLO WORLD.TXT"
-RUN
-TYPE &RETCODE
DOS DIR "HELLO WORLD.TXT"
-EXIT

Regards

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Master
posted Hide Post
Hakan

Another thing it might be is the Amper Autoprompter's annoying habit of removing backslashes from the code it passes onto the server. If you amper auto prompt you have to double up your backslashes because I think it gets treated as an escape character.

If anyone knows anything more about this and if it gets fixed in a later release, I would be interested to know.

Regards

John



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
Gold member
posted Hide Post
H. Lindholm,

I have experienced a non-functional STATE using FOCUS and unix. The alternative we used was to test the return code of the "ls" command. Hamm01j hinted at this solution, but to be explicit you may be able to deal with this annoying problem by doing something similar:

-DOS DIR "c:\path\to\my file.txt"
-IF &RETCODE NE 0 THEN GOTO OOPS;


WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Master
posted Hide Post
jbmuir

Yes you guessed right the way round is to copy to a file without the space (which works) and then do the STATE on the target file that contains no spaces.

Here is a solution to check for file name containing spaces C:\HELLO WORLD.TXT. The solution is for windows servers only. I'm sure there are better solutions out there and would love to know of them, but this works ok.

There are 2 levels to this problem

1. Amper autoprompt replaces backslashes in code.

Try this as a .fex .

-SET &FILENAME = 'C:\HELLO WORLD.TXT' ;
-TYPE &FILENAME

It works ok

Now try via the amper autoprompt. (Enter any data)

-SET &DUMMY = &DATA.Please Enter Data. ;
-SET &FILENAME = 'C:\HELLO WORLD.TXT' ;
-TYPE &FILENAME

You can see the backslash is stripped. You can get round this problem by doubling on the back slashes

-* File state_example.fex
-SET &DUMMY = &DATA.Please Enter Data. ;
-SET &FILENAME = 'C:\\HELLO WORLD.TXT' ;
-TYPE &FILENAME

But this does not work if amper autoprompt is not invoked.

-* File state_example.fex
-*SET &DUMMY = &DATA.Please Enter Data. ;
-SET &FILENAME = 'C:\\HELLO WORLD.TXT' ;
-TYPE &FILENAME


2. STATE does not work if there's a blank in the filename. Try this as a .fex:

-DOS ECHO HELLO > "HELLO WORLD.TXT"
-DOS TYPE "HELLO WORLD.TXT"
DOS STATE "HELLO WORLD.TXT"
-RUN
-TYPE &RETCODE
DOS DIR "HELLO WORLD.TXT"
-EXIT

The solution is as follows:


-* File state_example.fex

-* this is the ascii code for backslash
-SET &BS = HEXBYT(92,'A1') ;
-SET &FILENAME = 'C:' | &BS | 'HELLO WORLD.TXT' ;
-TYPE &FILENAME

-* Switch amper autoprompt on
-*SET &DUMMY = &DATA.Please Enter Data. ;

-* Create/Delete the file
-DOS ECHO HELLO > "&FILENAME"
-* WINNT DEL "&FILENAME"

-* can do DOS/WINNT or CMD to pass command to windows based O/S
CMD DEL TEST.TXT > NUL
CMD COPY "&FILENAME" TEST.TXT
CMD STATE TEST.TXT
-RUN

-IF &RETCODE EQ 0 THEN GOTO FILE_EXIST ;
-TYPE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-TYPE &FILENAME does not exist
-TYPE +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
-FILE_EXIST

It's a bit painful but works - someone must have something better!

Regards

John

This message has been edited. Last edited by: hammo1j,



Server: WF 7.6.2 ( BID/Rcaster) Platform: W2003Server/IIS6/Tomcat/SQL Server repository Adapters: SQL Server 2000/Oracle 9.2
Desktop: Dev Studio 765/XP/Office 2003 Applications: IFS/Jobscope/Maximo
 
Posts: 888 | Location: Airstrip One | Registered: October 06, 2006Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     Checking if file exists

Copyright © 1996-2020 Information Builders