file

file object, function in area file system

(beas 9.2 PL: 06) Older Versions: Use tool.<methode>

 

Name

Read

Write

Description

filecopy

 

x

 

Copy a file

Return will be stored into "value"

 

file.filecopy=c:\sourcefile.txt=d:\sourcefile.txt

if <value> n= -1 then

 messagebox=error$Error opening Sourcefile

 return failure

end if

if <value> n= -2 then

 messagebox=error$Error writing Targetfile

 return failure

end if

messagebox=ok$Copy file ok!

end

filemove

 

x

 

Copy a file

Return will be stored into "value"

 

file.filemove=c:\sourcefile.txt=d:\sourcefile.txt

if <value> n= -1 then

 messagebox=error$Error opening Sourcefile

 return failure

end if

if <value> n= -2 then

 messagebox=error$Error writing Targetfile

 return failure

end if

messagebox=ok$Copy file ok!

end

fileexists,fileexist

 

x

 

Check if the file exists.

Return will be stored in "value":

1 = File exists

0 = File do not exists

 

file.fileexists=<filename>

if <value> = 0 then

 meldung=error$File <filename> is not exist

end if

filelength

 

x

 

tools=filelength=<file>

 

Get the length of the file ( max. 2 GByte )

Return value will be stored in "value"

 

file.filelength=testlog.loc

messagebox=info$Log-Filesize: <value> Bytes

filesave

 

x

 

 

Return

0=error

1=ok

 

file.filesave=<filename>=<varname>

 

local string myvar=HelloWorld

local string myfile=c:\temp\testfile.txt

file.filesave=<myfile>=<myvar>

if <value> = 0 then

  message=error$file not saved!

elseif <value> =  1 then

  message=ok$ok

end if

filesaveudf8

 

x

Storing contens of a variable in a ansi coding file

filedelete

 

x

 

Return will be stored in "value":

1 = OK

0 = Error

 

file.filedelete=<cfile>

if <value> = 1 then

 messagebox=error$can not delete fole <cfile>

end if

fileload

 

x

 

Load the file into a variable

 

 

file.fileload=<filename>=varname=[<encoding>]

 

returns the text in variable <varname>

 

Example:

file.getfile=choose text file=*.txt=Textfile,*.txt

file.fileload=<filename>=ls_filetext

messagebox=<ls_filetext>

 

Encoding

if the file is ANSI or UTF8 you can convert this file in other endcoding-type

 

you can convert in

utf16le

uce2le

utf16be

uce2be

 

see

createdirectory

 

x

 

file.createdirectory=<directoryname>

 

file.createdirectory=c:\temp

if <return> = -1 then

 // errorscript

end if

 

directoryexists

 

x

 

file.directoryexists=c:\temp

if <value> = 1 then

 // directory exists...

end if

 

getdirectory

 

x

 

file.getdirectory=<defaultdirectory>

 

user can Choose a directory

return in value "value"

 

file.getdirectory=c:\

if <value> <>  then

 messagebox=you choosed the directory <value>

end if

 

directoryread, dir

 

 

 

read all entrys from a directory

no command, but solution with ue_datastorevalues

 

dtw=dir=<folder>=<filetype>

 

Types are:

0--Read/write files

1--Read-only files

2--Hidden files

4--System files

16--Subdirectories

32--Archive (modified) files

16384--Drives 32768--Exclude read/write files from the list

 

 

// example read directory with ue_datastorevalues

destroy=dtw

setvar=ls_test=

declare=dtw=ue_datastorevalues

// Read Temp-Folder

 

dtw=dir=c:\temp\*.*=32

 

for loop=1 to <dtw.rowcount>

 dtw=setrow=<loop>

 setvar=ls_test=<ls_test><dtw.filename> <dtw.filesize>,

next

destroy=dtw

messagebox=<ls_test>

 

getfolder

 

x

 

getfile

 

x

 

Open Windows-Choose-File-Box

 

Get a file.

 

Return will be stored in variable <filename> with pathname

and the pathname in <filepath>

 

two format

 

Short-Format

file.getfile=<title>=<extension>=<filter,defaut>

 

 

Long Format

Parameter with "<tab>"

file.getfile=propertie=value<tab>propertie=<value> (..)

 

title

A string whose value is the title of the dialog box.

path

A string whose value is the initial directory name. The default is the current directory.

extension

Extenstion, Example "*.*"

filter

Filter

Example

filter=Graphic Files,*.bmp;*.gif;*.jpg;*.jpeg,text-Files,*.txt

 

flag

The aFlag argument is used to pass one or more options that determine the appearance of the dialog box. For each option, the value of the flag is 2^(index -1), where index is an integer associated with each option as shown in the following table. You can pass multiple options by passing an aggregate flag, calculated by adding the values of the individual flags.

 

If you do not pass an aFlag, the Explorer-style open file dialog box is used. If you do pass a flag, the old-style dialog box is used by default. Some options do not apply when the Explorer-style dialog box is used. For those that do apply, add the option value for using the Explorer-style dialog box (2) to the value of the option if you want to display an Explorer-style dialog box.

For example, passing the flag 32768 (2^15) to the GetFileSaveName function opens the old-style dialog box with the Read Only check box selected by default. Passing the flag 32770 opens the Explorer-style dialog box with the Read Only check box selected by default

 

Index        Constant name        Description

1        OFN_CREATEPROMPT        If the specified file does not exist, prompt for permission to create the file. If the user chooses to create the file, the dialog box closes; otherwise the dialog box remains open.

2        OFN_EXPLORER        Use an Explorer-style dialog box.

3        OFN_EXTENSIONDIFFERENT        The file extension entered differed from the extensions specified in extension.

4        OFN_FILEMUSTEXIST        Only the names of existing files can be entered.

5        OFN_HIDEREADONLY        Hide the Read Only check box.

6        OFN_LONGNAMES        Use long file names. Ignored for Explorer-style dialog boxes.

7        OFN_NOCHANGEDIR        Restore the current directory to its original value if the user changed the directory while searching for files. This option has no effect for GetFileOpenName on Windows NT, 2000, and XP.

8        OFN_NODEREFERENCELINKS        Return the path and file name of the selected shortcut (.lnk file); otherwise the path and file name pointed to by the shortcut are returned.

9        OFN_NOLONGNAMES        Use short file names (8.3 format). Ignored for Explorer-style dialog boxes.

10        OFN_NONETWORKBUTTON        Hide the Network button. Ignored for Explorer-style dialog boxes.

11        OFN_NOREADONLYRETURN        The file returned is not read only and is not in a write-protected directory.

12        OFN_NOTESTFILECREATE        Do not create the file before the dialog box is closed. This option should be specified if the application saves the file on a netwrok share where files can be created but not modified. No check is made for write protection, a full disk, an open drive door, or network protection. A file cannot be reopened once it is closed.

13        OFN_NOVALIDATE        Invalid characters are allowed in file names.

14        OFN_OVERWRITEPROMPT        Used in Save As dialog boxes. Generates a message box if the selected file already exists.

15        OFN_PATHMUSTEXIST        Only valid paths and file names can be entered.

16        OFN_READONLY        Select the Read Only check box when the Save dialog box is created.

 

 

Example short Format

file.getfile=myfiles=*.txt=Textfile,*.txt

messagebox=<var:filename>

 

Example Tab-Format

// Check Access

window.mode=update

if <return> = -1 then

 return failure

end if

// get file

file.getfile=title=choose file<tab>path=<setup:mydefaultpath>

if <var:filename> =  then

 return failure

end if

// set file in my column filename

dw_1.item.filename.value=<filename>

// set path to default path

setsetup=mydefaultpath=<filepath>

 

 

 

shell

 

x

 

to variants from Shell:

 

if you've more then one line then beas create a batch-file in the temp-Folder, copy your script in this file and call this.

if you've only one line, beas call the file and send the command

 

Shell One Line

 

file.shell=calc

open the calculator

file.shell=myword.doc

open word (if installed) and open the document "myword.doc"

file.shell=www.beasgroup.com

open the internet-address www.beasgroup.com

setvar=myparameter=p=4986

setvar=myurl=<js.encodeURI('[myparameter]');>

file.shell=http://blog.beas-support.com/?<myurl>

 

set parameter to "p=4986", convert to URI-Code and open the internetexplorer with the beas-Blog with the URI-String

 

Shell with File-Action

if you want print a document, use tools=shell

file.shell=file=action

Example: Print a PDF-File:

file.shell=myword.pdf=print

 

Shell as Batch

if you want to call a batch-file, you can use

[shell]

script

[/shell]

 

beas create a batch-File with this script and call this.

Example

 

setvar=myvar=Hello World

[shell]

echo off

echo <myvar>

pause

[/shell]

 

 

if you want to print a PDF file directly to a defined printer (if you've installed Acrobat Reader), example:

 

[shell]

"c:\program files (x86)\adobe\acrobat reader dc\reader\acroRd32.exe" /n /s /h /t "H:\file.pdf" "<printername>"

[/shell]

 

 

The Dos-Window is minimized

run

 

x

 

runs a program with parameters:

 

file.run=<program>

file.run=maximized=<program>

file.run=minimized=<program>

file.run=normal=<program>

 

help-achtung only executable programs like EXE, COM or BAT are processed.

 

With the parameter maximized, minimized or normal you can specify the mode of the window.

 

help-hinweis you can also use the command "tools=shell=<file-name>" for opening documents, images...

 

help-beispielExample: opening help (*.chm) incl. Topic

file.run=hh [path\filename.chm]::/[topic.htm]

 

setvar=mytopic=capitel1

file.run=hh projekt\customer\myhelp.chm::/<mytopic>.htm

 

runandwait

 

x

execute a program and wait for ending

runandwaittime

 

x

time to wait befor the called Application, batch,.. will be closed

declare=systools=ue_system_tools

systools=runandwaittime=120

systools=userunandwait=true

systools=runbeas=script=opennewwindow=artikel_browse.psr

 

userunandwait

 

x

should the runandwait function be used instead of  the normal run. yes/no

declare=systools=ue_system_tools

systools=runandwaittime=120

systools=userunandwait=true

systools=runbeas=script=opennewwindow=artikel_browse.psr

 

 

 

 

rundll

 

x

 

file.rundll=<command>

 

execute rundll32.exe

runbeas

 

x

 

 

start beas in a separat task with the same user, pwd, database and server

 

example: execute the Script c:\temp\myscript

file.runbeas=script=$c:\temp\myscript.src

 

getfilesavename

 

x

 

Open windows-standard-window for save a file.

 

file.getfilesavename=Title=Extension=filefilter=startingdirectory=default filename

 

filefilter,startingdirectory and default filename are optional

 

file.getfilesavename=Filename=XLS=Excel (*.XLS),*.XLS=C:\temp

if <return> = success then

 message=<value>

end if