FileExists procedure

aviovda

New Member
hello

i would appriciate your kind help to guid me how
to check if a file is exist in a specified location
and to get a yes/no answer .

thank you.
 

gcampbell

Member
Progress offers two easy methods.

1. The SEARCH function:

Will search for a file in the PROPATH and return either the full path or ?

2. The FILE-INFO handle.

Set the FILE-INFO:FILE-NAME attribute to the location of the file then check another attribute (like FILE-INFO:FILE-TYPE) to determine if it is a valid file name (If file-type = ? then invalid, or if FILE-TYPE contains D then it's a directory).

Later,
Gordon
 

aviovda

New Member
i have a trouble seeking files outside the propath

i have a trouble seeking files outside the propath what you sugest please?
 

Claude Simon

New Member
Hi all,

Can you describe in which conditions is located your file ?
Is it located on a different server, sowhere on the web, do you need to pass through different IP adresses ? If, it is the case, you'll need to use http sockets, administrators of the distant server should open an security service to let you accede to your file.
If your file is in some racks, the communication throughe your network should be good.
Hope this helps.
 

aviovda

New Member
i will try to explain

thank you

the file is located under another non web server

but as far as i see it can be access from the web server, and from my local
station (i dont know if it is sufficiant i do not have any knowledge about sockets).

still
the command
search("f:\whatever\cal.gif").
will return "?" .

(f:\whatever\ is the fisical path where the file cal.gif is located.)

appriciate your kind help
 

Claude Simon

New Member
Well, you have to create or pirat a procedure of sockets, of demand and response http-sockets.
Unfortunately, I didn't conserve my code.

Well, if it is not a html server, but an unix server, administrator of this server has to create you a batch program, who will deliver you the file between the protocol (often sure integrity file protocol IP or more network secure protocol UDP, with the adequate port, and the IP V4 or maybe IP V6 address).

If it is a distant server, distanciated from your own network with the public network, your own administrator should apply rules in his firewall.
In this case, it won't be the protocol-port-address of the very distant administrator, but the protocol-port-adress furbished by your administrator, that you will parameter in your Socket-Something procedure.

Whatever, you must test BEFORE your procedure on local, with a distant test file in your network.
After that, you must be sure that your own network administrator has opened the network to this network.

So, I warn you of the risks of mis-understanding between your collegues.

Keep a touch ahead.
 

aviovda

New Member
hello to all
my purpose is to display to the user a list of field named part via select box, for items that have only some value in a field called "drawing", and that i can do with no problem.
the trouble is that there are cases in which the field "drawing" is not
empty but there is no file exist in the lan server my purpose is to prevent from those part from being displayed .


because i cant yet solve the problem and my administrator
is not available i thought that probably
there is a way you solve this with "js" combined.
i thought so because the client side can "see" with out any problem
the files in the directories of the lan server
and there may be a way to solve it in the client side .
attached the code

see the lines /***** this is what the problem about ****/

<TITLE>JavaScript Toolbox - Auto-Complete</TITLE>
<SCRIPT LANGUAGE="JavaScript" type="text/javascript" SRC="<A href="file://\\ddd\autocomplete.js"></SCRIPT">\\ddd\autocomplete.js"></SCRIPT>
</HEAD>
<body bgcolor=white text=blue>
<center><h1>Vendor-Parts & Drawings </h1></center><hr>
<h3> Select Parent </h3>
<FORM ACTION="drawven.html" METHOD="get" style= "HIGHT: 22PX;WIDTH: 220px">
<INPUT TYPE="text" NAME="part_id" VALUE="" ONKEYUP="autoComplete(this,this.form.options,'value',true)">
<SELECT NAME="options"
onChange="this.form.part_id.value=this.options[this.selectedIndex].value" size="10">
<!--WSS
def var i as char init "bb".
def var sfile like pt_desc1.
def var ppath as char format "(90)".
def var ch-fso as com-handle no-undo.
def var c-filename as char.
def var retval as log no-undo.
for each pt_mstr no-lock by pt_part:

/*****this what the problem about
/*i = search(pt_draw).
if i <> ? then do:*/ *******/
-->
<OPTION value = `pt_part` > `pt_part` </OPTION>
<!--WSS
/*end*/
end.
-->
</SELECT>
</p>
<INPUT type="submit" value=submit name=submit1>
</FORM>
</BODY>
</HTML>
 

Claude Simon

New Member
Hi Aviovda,

Well, if I understood, you need to test the existence of distant files to aliment select-box, isn't ?

Effectively, if it's the case, javascript testing should be sufficient.
See the empty response (I suppose it's "?" or other) and exclude it.

Whatever, I'm not an expert of speedscript (Casper is stronger than me in
this domain), but you talk about javascript solution, and your the code of your procedure isn't viewable.
 

Casper

ProgressTalk.com Moderator
Staff member
Hi Aviovda,

the trouble is that there are cases in which the field "drawing" is not
empty but there is no file exist in the lan server my purpose is to prevent from those part from being displayed .

If I understand correctly, the field drawing consists of a file name and the parts only need to be displayed if the field drawing is empty or not empty and the file exists.

Your code:
Code:
<% for each pt_mstr no-lock by pt_part:
 
    if pt_daw = '' OR
       search(pt_draw) <> ?
    then do:
%>
   <OPTION value =<%=pt_part%>><%=pt_part%> </OPTION>
<%
    end.
end.
%>

Should work if the file is within the propath.
But you say the files are on a LAN server, probably a different server then where the database resides. Is the value of pt_draw an absolute path at the Lanserver, or just a file name?

You can't solve this problem with javascript.
If your database machine is a windows machine then you can make a mapped drive to the specified place at the Lan server and with file-info handle you can find out if the file exists. If it isn't a windows server then you have to make your self a (progress) routine to verify if file exists at that server.
There are more then one ways to accomplish that.

Anyway I think this kind of logic shouldn't be in the HTML page with webspeed, but in a normal .p procedure which you can call form the dispatch procedure you probably already made for your WebSpeed application.


HTH,

Casper.
 
Top