[..] Comment copier le résultat la de fonction _ArrayDisplay() dans un fichier texte sans changer la mise en forme ?
Posté : jeu. 24 sept. 2020 10:48
Bonjour,
En utilisant la fonction _FileWriteFromArray(), comment copier le résultat obtenu par la fonction _ArrayDisplay() dans un fichier texte sans changer la mise en forme du tableau . Voir l'exemple du code ci-dessous:
Merci pour votre aide.
Cordialement.
En utilisant la fonction _FileWriteFromArray(), comment copier le résultat obtenu par la fonction _ArrayDisplay() dans un fichier texte sans changer la mise en forme du tableau . Voir l'exemple du code ci-dessous:
Merci pour votre aide.
Cordialement.
#include <Array.au3>
#include <File.au3>
#include <MsgBoxConstants.au3>
$input = @ScriptDir & '\TOTO.ini'; @ScriptDir & '\Config.ini'
If Not FileExists($input) Then
MsgBox(48, 'Error', ' File Not Found ')
Exit
EndIf
Global $output[1][1]; init ini array
_Ini_Array_Rows()
Func _Ini_Array_Rows()
Local $ct, $sn, $rs; common declares
Local $MaxKeyCt = 0; init max key counter
Local $sn_tick = 0; init section counter
$sn = IniReadSectionNames($input); read sections
While 1; loop 1
$sn_tick += 1; advance counter
$rs = IniReadSection($input, $sn[$sn_tick]); read keys
If @error = 1 Then ContinueLoop; If empty section then continue counting
If $rs[0][0] > $MaxKeyCt Then $MaxKeyCt = $rs[0][0]; get max keys
If $sn_tick = $sn[0] Then ExitLoop; exit loop when total reached
WEnd
ReDim $output[$sn[0]][$MaxKeyCt + 1]; resize needed array
$sn_tick = 0; reset section counter
While 1; loop 2
$sn_tick += 1; advance counter
$rs = IniReadSection($input, $sn[$sn_tick]); read keys and values
If @error = 1 Then; If empty section
$output[$sn_tick - 1][0] = $sn[$sn_tick]; then insert section name
ContinueLoop
EndIf
For $ct = 1 To $rs[0][0]; loop 3
$output[$sn_tick - 1][$ct] = $rs[$ct][1]; arrange array
Next
$output[$sn_tick - 1][0] = $sn[$sn_tick]; add section name to column 0
If $sn_tick = $sn[0] Then ExitLoop; exit when done with last section
WEnd
Return $output
EndFunc
;;*** _ArrayDisplay($output, "Result"); display ini array (rows)
$Resultat01 = _ArrayDisplay($output, "Liste des étudiants du cours à distance: TEC", Default, 64+16, @TAB, "C.N.E|Civilité|Nom de famille|Prénom|Date de naissence|E-mail académique|Email personnel|Téléphone GSM|N° WhatsApp|Département")
;=======================================
; Copier le résultat obtenu à l'aide de la fonction _ArrayDisplay() dans un fichier texte.
Local $aRetArray, $sFilePath = @TempDir & "\Test.txt"
; Ecrit dans le fichier
_FileWriteFromArray($sFilePath, $output ,Default, Default, "|")
Sleep(1000)
Exit
#include <File.au3>
#include <MsgBoxConstants.au3>
$input = @ScriptDir & '\TOTO.ini'; @ScriptDir & '\Config.ini'
If Not FileExists($input) Then
MsgBox(48, 'Error', ' File Not Found ')
Exit
EndIf
Global $output[1][1]; init ini array
_Ini_Array_Rows()
Func _Ini_Array_Rows()
Local $ct, $sn, $rs; common declares
Local $MaxKeyCt = 0; init max key counter
Local $sn_tick = 0; init section counter
$sn = IniReadSectionNames($input); read sections
While 1; loop 1
$sn_tick += 1; advance counter
$rs = IniReadSection($input, $sn[$sn_tick]); read keys
If @error = 1 Then ContinueLoop; If empty section then continue counting
If $rs[0][0] > $MaxKeyCt Then $MaxKeyCt = $rs[0][0]; get max keys
If $sn_tick = $sn[0] Then ExitLoop; exit loop when total reached
WEnd
ReDim $output[$sn[0]][$MaxKeyCt + 1]; resize needed array
$sn_tick = 0; reset section counter
While 1; loop 2
$sn_tick += 1; advance counter
$rs = IniReadSection($input, $sn[$sn_tick]); read keys and values
If @error = 1 Then; If empty section
$output[$sn_tick - 1][0] = $sn[$sn_tick]; then insert section name
ContinueLoop
EndIf
For $ct = 1 To $rs[0][0]; loop 3
$output[$sn_tick - 1][$ct] = $rs[$ct][1]; arrange array
Next
$output[$sn_tick - 1][0] = $sn[$sn_tick]; add section name to column 0
If $sn_tick = $sn[0] Then ExitLoop; exit when done with last section
WEnd
Return $output
EndFunc
;;*** _ArrayDisplay($output, "Result"); display ini array (rows)
$Resultat01 = _ArrayDisplay($output, "Liste des étudiants du cours à distance: TEC", Default, 64+16, @TAB, "C.N.E|Civilité|Nom de famille|Prénom|Date de naissence|E-mail académique|Email personnel|Téléphone GSM|N° WhatsApp|Département")
;=======================================
; Copier le résultat obtenu à l'aide de la fonction _ArrayDisplay() dans un fichier texte.
Local $aRetArray, $sFilePath = @TempDir & "\Test.txt"
; Ecrit dans le fichier
_FileWriteFromArray($sFilePath, $output ,Default, Default, "|")
Sleep(1000)
Exit