pralash
13th October 2017, 09:46
Hi,
I'm new for LN Programming... I want to know that how to find out the particular directory or folder is available or not in the specified path... Can anybody please let me know that how to perform this task.

Thanks in advance,
Regards,
Pralash

JaapJD
13th October 2017, 12:08
Function file.stat() or stat.info()

pralash
13th October 2017, 13:32
Thank you so much for your reply...
But I could not able to find the specified directory in a path by using file.stat() or stat.info() function... These are only returns the information about the file such as file size etc... So can you please tell me some another function for find out whether the specified directory is available or not in local system....

Regards,
Pralash

bdittmar
13th October 2017, 14:26
Hello,

Client file access synopsis

long
client2server() ( string source, string dest, boolean text.mode [, boolean rm.file] [, boolean progress.window] )

long
create.local.directory() ( string dirent )

long
create.local.file() ( string filename )

long
dir.select.dialog.local() ( ref string dirent )

long
get.client.hostname() ( ref string hostname )

long
get.client.ip.address() ( ref string ip.address )

string
get.local.filename() ( )

long
remove.local.directory() ( string dirent )

void
remove.local.file() ( string filename )

long
seq.fstat.local() ( string filename, ref long nr.bytes )

long
seq.open.dialog.local() ( const string defaultname, const string directory, const string filter, ref string filename )

boolean
seq.open.dialog.next() ( ref string filename )

long
seq.saveas.dialog.local() ( const string defaultname, const string directory, const string filter, ref string filename)

long
server2client() ( string source, string dest, boolean text.mode [, boolean progress.window] [, boolean read.only] )

long
start.application.local() ( const string commandline, boolean waitFlag, reference long exitCode, [const string verb] )

void


Use these functions to perform various operations on client files and other client operations – for example:

to open, read, write to, close, and delete files on a client
to show a file open or directory chooser dialog on a client
to transfer files between client and server
to retrieve client file information
to create and delete directories on a client
to start an application on a client
to retrieve client hostname and IP address
to show a color selection dialog on a client
Note
You can use most of these functions both with the Baan Windows and with the Webtop client. However, some functions are only supported for the Baan Windows client and therefore deprecated.

Regards

mark_h
13th October 2017, 14:33
What exactly are you trying to accomplish with the path? I know we are on unix, but we typically are asking for file names. If they give you a directory - you can always try to create a file in the path - if it works great - if not just give them an error.

bhushanchanda
14th October 2017, 09:51
Here's a similar thread. (http://www.baanboard.com/baanboard/showthread.php?t=60116)

Hope this helps

pralash
14th October 2017, 10:40
Thank a lot for your reply...
Actually I need to create a session for a customization work... In this customization, I have to perform the following task.

1. A new folder would be created in the name of "Test" under the BSE path(C:\ERPLN) if I execute the session in the first time...
2. Then a new file would be created in the name of "sample.txt" under the path like that C:\ERPLN\Test\sample.txt.
3. I need to store some data into that file (sample.txt) from the "table A" .
4. I have created a directory "Test" by using the mkdir function under the BSE path.
5.Then I opened a new file sample.txt by using file.pointer = seq.open(file.name, "w")...
6.I have stored the necessary data into the file by using seq.puts function...
7.Here now I need to check the directory "Test" is available or not... If it is not available then I create this by using mkdir otherwise I have to prompt the message such as "Directory is already exist"...
Hence can you please tell me how to check whether the specified folder is available or not in a particular path....
Sample script:

if isavailable("test") then
message "Already exist"
else
mkdir("test")
endif

Can you please tell me the baan script exact to the script above...
Regards,
Pralash

mark_h
14th October 2017, 20:35
Well we do not test for the directory. In this example we just try to download a file to the windows client m: drive. If it errors we just create the directory. Notice the coder commented out the piece that gave an error. You could just mkdir the directory everytime - if it exists just skip the error.


function send.report.to.client(const string src(), const string dest(), const string dest2())
{
long err, dir

err = server2client(src, dest, 1)
if (err) then |20061025
dir = create.local.directory("m:\baantmp\") |20061025
| if (dir) then |error 183 must mean it already exists
| message("Error %d creating m:\baantmp\", dir)
| endif
err = server2client(src, dest2, 1) |20061025
if (err) then |20061025
message("Error %d copying file to PC (may not have permission)",
err)
endif |20061025
endif
}

pralash
16th October 2017, 08:13
Thanks for your information to implementation of my task.

Have a doubt for using the "mkdir" function... I have created a new directory under the path "C:\ERPLN\Test" while execution of first time for my session...
After that I have created a file "data" and stored some another information from the table of baan..

But whenever we execute the session repeatedly, whether the "Test" folder and it contents is overwrite or not?

Can you please clear my doubt.... Thanks...
Regards,
Senthil

mark_h
16th October 2017, 14:37
If the folder exists the mkdir should not over-write it. My best recommendation is to write the code and run in debug mode to see that happens watching each step.

bhushanchanda
16th October 2017, 15:03
Hi,

Here's a sample. Also, just for your information, mkdir can only be used to create directories on Server and not on client machine. I've added a sample to check if path exists already. Also, the file will be copied to clients temp directory which can be accessed using %TMP% from your Run Command(Windows+R)

long fp
string file(100)

ret = dir.open("${BSE}\Temp") |# Open directory
if ret > 0 then |# If already exists, do nothing
else
mkdir("${BSE}\Temp") |# If doesn't exists, create it.
dir.close(ret)
endif

file = "${BSE}\Temp\Sample.txt"
fp = seq.open(file,"w+")

|***********WRITE DATA TO FILE******************
select tcibd001.*
from tcibd001
as set with 1 rows
selectdo
seq.puts(tcibd001.item,fp)
endselect

seq.close(fp)

|************ Copy File to Client Machine's default Temp folder**************
server2client(file,"${TMP}\Sample.txt",true)

pralash
6th November 2017, 11:26
Apologize for the delay response....
It's working fine....
Thanks so much...

Regards,
Pralash