ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / Managing databases / HFSQL / HFSQL functions
  • Importing a Text Memo item
  • Importing a Binary Memo item
  • Importing an indexed item
  • Importing a Time item
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
<Source>.ImportText (Function)
In french: <Source>.ImporteTexte
ODBCNot available with this kind of connection
Imports a Text file into a data file in HFSQL Classic or Client/Server format (data file described in the data model editor, or declared by <Source>.Declare, <Source>.DeclareExternal or <Source>.DescribeFile).
Remark: If the HFSQL data file used does not physically exist, it will be automatically created.
Example
// Importe le nom, l'adresse et le logo (mémo binaire) des clients.
// On réinitialise les autres rubriques.
// Une ligne du fichier d'importation contient donc 3 ou 5 colonnes:
// - Nom, - Adresse, - Nom du fichier pour le logo
// (si le nom du fichier pour le logo est différent
// de chaîne vide, 2 colonnes supplémentaires)
// - Le type du mémo (IMG), - Un commentaire
IF Client.ImporteTexte("C:\UnExemple\Client.txt", "NOM,ADRESSE,LOGO", hDefaultVal, "Jauge1") = False THEN
	Error("Importation impossible")
ELSE
	// Traitement
END
// Ce fichier sera importé
sCheminFichierTexte is string = "ImportJoueur.txt"

// Contenu de ce fichier (2 lignes):
// "JoueurImport1","19850618"
// "JoueurImport2","19900512"

// sNomJoueur et dDateNaissance sont 2 rubriques du fichier Joueur de type chaîne et Date

IF Joueur.ImporteTexte(sCheminFichierTexte, "sNomJoueur,dDateNaissance", ...
    "," + Charact(127) + """" + Charact(127) + CR + Charact(127) + ".") THEN
	...
ELSE
	...
END
Syntax
<Result> = <Source>.ImportText(<Full path of text file> , <List of items> , <Separators> [, <Options> [, <Progress Bar>]])
<Result>: Boolean
  • True if the operation was performed,
  • False if an error occurred. HError returns more details about the problem.
<Source>: Type corresponding to the specified source
Name of the HFSQL data file into which the import must be performed.
<Full path of text file>: Character string
Full access path to text file to import.
<List of items>: Character string
List of item names in the text file. The names can be delimited by single quotes and they are separated by commas or CR characters. The names of composite key items are ignored.
If this parameter is not specified or corresponds to an empty string (""), all items are imported (except compound keys) in the order in which they were created in the physical file.
<Separators>: Character string
List of separators used for columns, strings, rows and decimal places.
The different separators are separated by Charact(127) (for backward compatibility with WINDEV 5.5).
<Séparateur de colonnes> + Caract(127) + <Séparateur de chaînes> + Caract(127) +
<Séparateur de lignes> + Caract(127) +<Séparateur de décimales>
  • <Column separator>: Character string (", " by default).
  • <String separator>: Character (" by default)
  • <Row separator>: Character string (CR by default, which means Charact(13)+Charact(10))
  • <Decimal separator>: Character ("." or "," by default)
<Options>: Optional Integer constant (or combination of constants)
Configures the type of import to perform:
hCopyAutoIDThe automatic identifier is copied. It is not recalculated.
hImpCreationIf the import data file exists, it is overwritten.
hImpIgnoreFirstLineThe first row of the imported file is ignored.
hImpIgnoreInvalidLineThe lines whose structure are invalid are not imported: the import continues on the following lines.
The structure is invalid if data is missing for one or more items, or if string separators are missing.
hImpIgnoreEmptyItemIf one or more items are not filled in the text file, the corresponding lines are still imported.
The missing items contain:
  • the default value of items if the hDefaultVal constant is specified.
  • the value of items in the current record before the call to <Source>.ImportText.
hImpBreakableThe import can be interrupted by pressing the Esc key (parameter ignored on the data files in 5.5 format).
If the import is interrupted, the imported records are kept in the data file. A re-index operation is automatically performed if necessary (cannot be interrupted).
hImpNormal
(default value)
If the import data file already exists, it is filled with the imported data ; otherwise, the data file is created.
No management of integrity and no management of duplicates.
The non-imported items take the value of the current record.
The string delimiters are used.
The automatic identifiers are recalculated.
OLE DBNative Connectors (Native Accesses) The management of integrity and duplicates is always enabled.
hImpOEM2ANSIThe imported strings are automatically converted from OEM to ANSI.
hImpNoDelimiterThe string separators (if they exist) are part of the item.
hImpTestDuplicatesEnables the management of duplicates on unique keys during the import (the management of duplicates is enabled on unique keys only and not on the entire record).
OLE DBNative Connectors (Native Accesses) The management of duplicates is always enabled.
hImpTestIntegrityChecks the integrity during the import.
OLE DBNative Connectors (Native Accesses) The management of integrity is always enabled.
hDefaultValFor the non-imported items, the values of the current record are reinitialized:
  • with their default value if the hDefaultVal constant is specified.
  • with the value of the corresponding items in the current record before the call to <Source>.ImportText if the hDefaultVal constant is not specified.
<Progress Bar>: Optional control name or window name
  • Name of the window in which the progress bar will be displayed,
  • Name of the Progress Bar control.
WEBDEV - Server code This parameter is not available.
Remarks
WINDEVWEBDEV - Server codeUniversal Windows 10 AppiPhone/iPadIOS WidgetMac CatalystAjaxHFSQL ClassicHFSQL Client/ServerStored proceduresHyper File 5.5

Importing a Text Memo item

  • The hImpNoDelimiter constant is not specified:
    The text to import can contain <Row separator> or <Column separator>. The text to import must not contain any <String separator>.
  • The hImpNoDelimiter constant is specified:
    The text to import must not contain any <Row separator> or <Column separator> otherwise they will be taken into account as such. The text to import can contain <String separator>.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystJavaAjaxHFSQL ClassicHFSQL Client/ServerStored proceduresHyper File 5.5

Importing a Binary Memo item

For a binary memo item, 3 columns are associated in the text file.
  • Column 1: full path of the binary file that must be added to the memo. This is a character string. If this string is empty, the two following columns must not be specified in the text file.
  • Column 2: type of the memo. This is a character string that is set to:
    • "IMG" to indicate that the file is an image file.
    • "WAV" to indicate that the file is a sound file.
    • "OLE" to indicate that the file is an OLE file.
    • "BIN" (or other) to indicate that the file is an ordinary binary file.
  • Column 3: information message. This is a character string (up to 65535 characters. If it is larger, the string is truncated).
Structure of text file to import:
The following items must be imported:
  • <LASTNAME>: text item
  • <AGE>: numeric item
  • <FIRSTNAME>: text item
  • <COMMENT>: text memo
  • <PHOTO>: image binary memo
The following delimiters are used:
  • <String separator>: "
  • <Column separator>: ,
  • <Row separator>: CR
If the hImpNoDelimiter constant is not specified: "LASTNAME", AGE, "FIRSTNAME", "COMMENT", "file of PHOTO memo", "type of PHOTO file", "info of PHOTO memo"+CR
If the hImpNoDelimiter constant is specified: LASTNAME, AGE, FIRSTNAME, COMMENT, file of PHOTO memo, type of PHOTO memo, info of PHOTO memo+CR
Each content can be empty.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystJavaAjaxHFSQL ClassicHFSQL Client/ServerStored proceduresHyper File 5.5

Importing an indexed item

<Source>.ImportText cannot be used to import indexed items.
WINDEVWEBDEV - Server codeUniversal Windows 10 AppAndroidAndroid Widget iPhone/iPadIOS WidgetMac CatalystJavaAjaxHFSQL ClassicHFSQL Client/ServerStored proceduresHyper File 5.5

Importing a Time item

<Source>.ImportText saves invalid times if the times to import are not in one of the formats available in the analysis.
Reminder: the following formats are available in the analysis:
  • HH
  • HHMM
  • HHMMSS
  • HHMMSSCC
Component: wd300hf.dll
Minimum version required
  • Version 25
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 07/09/2024

Send a report | Local help