Arlina
25th April 2019, 13:26
Hi
Does dir.open() open directory from local machine or server?
eduardourra
25th April 2019, 13:30
Hi,
dir.open() work on server side
Arlina
25th April 2019, 13:35
If i want to open local folder, is there any function available?
mark_h
25th April 2019, 16:29
Not that I am aware. Search on dir.open and look at the threads. The older ones talk about executing commands to move the folders to the baan server.
bdittmar
25th April 2019, 20:30
Hi
Does dir.open() open directory from local machine or server?
Client file access overview:
Client file access overview
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.
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
color.dialog() ( reference long io.color )
Deprecated functions
long
app_start() ( string commandline, string directory, string stdin, string stdout, string stderr )
long
app_status() ( long app.id )
void
seq.close.local() ( long lfn )
long
seq.open.local() ( string filename, string mode(2) [, long remove.after.use] )
long
seq.read.local() ( ref string buf, ref long size, long lfn )
or sec.local functions
seq.open.local()
Syntax:
function long seq.open.local (string filename, string mode(2) [, long remove.after.use])
Description
Deprecated. This function is only supported for Baan Windows and its usage is therefore deprecated. Instead you should use functions: server2client() or client2server().
This opens a specified file on the client system. It returns a file pointer, which you can use to identify the file in subsequent operations.
Arguments
string filename The name of the file that must be opened. If you do not specify a path name, the file is searched for in the directory where BW is loaded.
string mode(2) The mode in which the file must be opened. This can be one of the following options:
"r" Open for reading.
w" Create for writing.
"a" Open for writing at end of file, or create for writing.
In addition, you can add "t" to any of the above options if you want the file to be opened in text mode.
[long remove.after.use ] Use this optional argument to specify whether or not the file must be removed after it has been closed by seq.close.local():
<>0 file is removed
0 file is not removed
Return values
>=0 Success. File pointer is returned.
<0 Error. File could not be opened.
Context
This function can be used in all script types.
Note
You cannot use Client file access overview functions in combination with the seq.*.local() functions. So, you cannot use seq.seek() or seq.rewind(), for example, on a file that was opened with seq.open.local().
Example
seq.open.local("C:\Program Files\Test.txt", "rt", false)
Regards
Arlina
26th April 2019, 06:43
I came across these functions. But I need functions which can handle local folder the way dir.open() is doing with server, without opening an dialog box as I need these functions for automation.
We have files in local folder.
Currently user selects Sales Quotation from overview session, click on Attachment button on the session, answers "File Linking" on the following question, then session dmdoc4540m002 appears.User than fills the details and browse file from the local folder and upload it.
We need to automate it now and run it through job.
The issues I am facing is
How to get file from local folder path (eg.C:\upload\<Quotation No>\) and use it in stpapi.put.field( "dmdoc4540m002", "filename", "file_from_local_folder")?As I am not getting any function like dir.open() for local folder
Any suggestions?
mark_h
26th April 2019, 14:45
If you know the directory is c:\upload\<quotation no> here is what I would do. As part of the automation I would either have the user to give me the quotation number. Then I would use seq.open.local on the file name to make sure the file exists - if not I would generate an error or give the user a message. After opening the file I would close it with seq.close.local. If it existed I would then use client2server to move the file to some place on the baan servers.
function domain tcbool open_file()
{
long rc
| Create temporary file to copy the PC file to
temp.file = creat.tmp.file$(bse.tmp.dir$())
temp.file = strip$(temp.file)
| Open PC file to make sure it exists.
inputfile = seq.open.local(input.file,"r",0)
if(inputfile<0) then
file_err(inputfile)
return(true)
endif
seq.close.local(inputfile)
rc = client2server(input.file,temp.file,0)
| Open Server file for processing.
inputfile = seq.open(temp.file,"r")
if(inputfile<0) then
file_err(inputfile)
return(true)
endif
return(false)
}
Now if when you run you need the file names, then what you could do is run a dos command, put the c:\upload\ files names into a txt file. Upload and read the file on the server. I think I saw something like that when I searched on dir.open. Let me see if I can find it again. Here is one such thread http://www.baanboard.com/baanboard/showthread.php?t=9091&highlight=dir.entry.
The api code is completely different - never done any kind of attachments with a function server of any sort.
Arlina
28th April 2019, 10:44
What we require is to run the automation without user intervention (as a job probably).
The program needs to find all the subfolders(named as per sales quotation no.) in C:\upload\
For available quotation no. it would run AFS of Sales Quotation Overview and handle File linking session as subprocess to upload the file with path C:\upload\<Quotation no.>\<filename>
Basically I need the local path of each file, not to open the file but to put it as an input in File Linking session.
Arlina
2nd May 2019, 10:23
Thanks all.
Finally what I used is
path.client= "C:\temp\ODM\"
cm = app_start("cmd.exe /C " &
"dir /AD /B /ON /S "&strip$(path.client)&
" >" & strip$(listd.f),
"", "", "", "")
suspend(1000) |to list of folders' path
|move listd.f to server using client2server()
.
.
.
cm1 = app_start("cmd.exe /C " &
"dir /b /a-d "&strip$(path.client1)&
" >" & strip$(listf.f),
"", "", "", "") |path.client1 from listd.f
|list of files within the folder
|move listf.f to server using client2server()
NPRao
9th October 2019, 20:41
I came across these functions. But I need functions which can handle local folder the way dir.open() is doing with server, without opening an dialog box as I need these functions for automation.
We have files in local folder.
Currently user selects Sales Quotation from overview session, click on Attachment button on the session, answers "File Linking" on the following question, then session dmdoc4540m002 appears.User than fills the details and browse file from the local folder and upload it.
We need to automate it now and run it through job.
The issues I am facing is
How to get file from local folder path (eg.C:\upload\<Quotation No>\) and use it in stpapi.put.field( "dmdoc4540m002", "filename", "file_from_local_folder")?As I am not getting any function like dir.open() for local folder
Refer to the latest Programmer's Manual -
seq.open.dialog.local()
Syntax:
#include <bic_desktop>
function long seq.open.dialog.local (boolean mselect, string defaultname, string directory, string filter, ref string filename)
Description
Deprecated. This shows the Windows file-open dialog, to allow the user to select one or more local files.
Arguments
boolean mselect When true, multiple select is allowed by the user else only one file can be selected by the user.
string defaultname The default filename shown in the file-open dialog.
string directory The startup directory for this dialog. In case of an empty string the "My Documents" directory will be the default. This parameter may include the string ${BSE_TMP} which indicates the ${BSE}\tmp directory in case of Baan Windows or Windows temp directory in case of WebUI.
string filter This argument specifies all possible file extensions for the file. The string must contain pairs of strings that are separated by a "|" character. The first string in each pair is a filter name (for example: "Text Files"). The second string must be a filter patern (for example: "*.txt"). Multiple filter patters can be specified by separating the filter patterns with a semicolon. Example: "All Files(*.*)|*.*|Text Files(*.txt) Word documents(*.doc)|*.txt;*.doc"
ref string filename Output argument which will contain the full path of the file selected by the user. In case mselect is true possible other selected file names can be retrieved using function seq.open.dialog.next()
Return values
>0 Number of files selected by the user.
0 File open dialog canceled by the user.
-1 Error occurred
Context
This function is implemented in the 4GL Engine and can be used in all script types.
This function is marked as 'untrusted' and can therefore only be used in trusted objects. More about trusted and not trusted objects can be found in the section about managed execution..
Notes
This function is not supported in LN UI. See the Implementing LN UI support for more information.
NPRao
9th October 2019, 20:47
Also refer to these threads for the select.file() usage -
http://www.baanboard.com/baanboard/showthread.php?t=1844&highlight=select.file
How can I copy a file from the server to a certain path (http://www.baanboard.com/baanboard/showthread.php?t=10603&highlight=otgbrg0019)
ren_bsi
4th July 2020, 12:24
Refer to the latest Programmer's Manual -
Dear NPRao,
Sorry for asking this ridiculous question since i'm still newbie in LN programming.
What is the meaning of "ref" in ref string filename ?
Why don't we add another "ref" before string directory, string filter ? :confused:
function long seq.open.dialog.local (boolean mselect, string defaultname, string directory, string filter, ref string filename)
Thank you :)
Best regards,
ren_bsi
DDPatel
4th July 2020, 13:38
Hiiii @ren_bsi
ref is use for return the reference value via function.
I show you one example for better understanding.
Example
You have item code and you are calling item description from ref variable.
domain tcdsca ret.dsca
|Function call
item.description (tdpur401.item ,ret.dsca) | tdpur401.item is I/P field and ret.dsca is O/P field
|Functions definition
Function item.description( domain tcibd001 fn.item,
ref domain tcdsca fnr.dsca)
{
select tcibd001.dsca:fnr.dsca
from tcibd001
where tcibd001.item = :fn.item
selectdo
endselect
}
I hope your doubt will be cleared for "ref"...
Regard,
DDPatel
ren_bsi
8th July 2020, 04:18
Hiiii @ren_bsi
ref is use for return the reference value via function.
I show you one example for better understanding.
Example
You have item code and you are calling item description from ref variable.
domain tcdsca ret.dsca
|Function call
item.description (tdpur401.item ,ret.dsca) | tdpur401.item is I/P field and ret.dsca is O/P field
|Functions definition
Function item.description( domain tcibd001 fn.item,
ref domain tcdsca fnr.dsca)
{
select tcibd001.dsca:fnr.dsca
from tcibd001
where tcibd001.item = :fn.item
selectdo
endselect
}
I hope your doubt will be cleared for "ref"...
Regard,
DDPatel
Dear DDPatel,
Thank you so much for your kind explanation :)
Best regards,
ren_bsi