File manipulationThe 'File' typeIn Storga, files are 'File' type variables. var File f Get the file name: var Str s := f name Change the file name: f name := "aute.txt" Get file date: var DateTime dt := f datetime Change the date of the file (with the current time in the example below): f datetime := datetime Get file size: var Int s := f size Obtain the display mode of the file block: var Str s := f display Change the display mode of the file block: f display := "open" The keywords that define the display mode of a file block are (several can be used separated by spaces):
Get the title associated with the file: var Str s := f title Associate a title to the file: f title := "Le logo de l'entreprise" Get the summary associated with the file: var Str s := f resume Associate a summary to the file: f resume := "Version n°3[lf]Créée le 12 novembre 2013 par Lorent" Organize filesBrowse the different file blocks of the current page or sheeteach_file f each_file f sheet Store the file in a page, a sheet, an emailnew_file f ... The position options that can be used by 'new_file' are the same as those used by 'new_form'. Move itmove_file f ... The position options usable by 'move_file' are the same as those usable by 'new_form'. Delete itdelete_file f Handle a file as a wholeMake a file from Storga contentwrite_file f "fichier.csv" "options_de_formatage" from report "identifiant_storga_de_l_etat" The export type is defined from the extension in the file name. The following extensions are defined:
If you export a Storga form to PDF, you can use the keyword 'print' in formatting options to get the print version of the document. Syntaxe obsolèteJusqu'en 2021, on utilisait une instruction 'export_as_file' au lieu de l'instruction 'write_file'. f := export_as_file "identifiant_storga_de_la_page_ou_du_formulaire" "fichier.html" "options_de_formatage" Instead of the identifier of a Storga block, 'export_as_file' can take a data of type 'Dataware' as its first argument. In this case, the possible export formats are .csv and .json. Convert a fileThe 'convert_file' function is very useful for converting between various file formats, for example from .doc to .pdf The simplest syntax is: var File f2 := convert_file f "foo.pdf" "" In case of failure in the conversion, it may be interesting to recover the error code in a variable, here 'e': var File f2 := convert_file f "foo.pdf" "" error (var Str e) For information, the old syntax was: var Str err := convert_file f "foo.pdf" "" (var File f2) Exchange a file with a server→ See the client part of the article 'HTTP and FTP interface' Provide to userCause a file download: download_file f A scenario for using this function is in a form, the user presses a button which causes the production of a file and offers the user to download its content. Read or write the contents of a fileThe end of this document specifies the functions available to read or write certain types of files. Obviously, unfortunately, Storga does not provide functions allowing to read all the types of files, nor even all the possible operations on the types of supported files. The supported file types are:
▸ Read or write a text file ▸ Read or write a CSV file ▸ Creation of an XML, Json and possibly other file by substitution in an example file ▸ Reading an XML or JSON file ▸ Read / write to a spreadsheet file ▸ Lire le texte dans un fichier image ou un fichier PDF (fonction OCR) ▸ Composition / decomposition of ZIP or PDF files |