Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

La propriété Multiligne de l'objet texte devra être cochée si vous voulez pouvoir voir le retour à l'écran).


...

Date, Time

...

et Timestamp

1 -

...

Effectuer des calculs sur des type date, time

...

et timestamp

...

Afin d'effectuer des calculs sur des types

...

In order to calculate Date, Time and ou Timestamps, we can use the following functionson utilisera les fonctions prédéfinies suivantes :

  • &CalculateCalcul_Date
  • &CalculateCalcul_TimeHeure
  • &CalculateCalcul_TimestampTimestp


Bloc de code
/* ___ DeclarationsDéclarations _____________________________________________________________________
date        myDate
date        myNewDate
time_t        MyTime
time_t        MyNewTime
timestamp   MyTimestamp
timestamp   MyNewTimestamp

/* ___ Code _____________________________________________________________________________
myNewDate = &calculatecalcul_date(myDate;1;'Y')                      /* addajouter 1 Yearannée toà myDate
myNewDate = &calculatecalcul_date(myDate;-6;'M')                     /* substractsoustraire 6 Monthsmois toà myDate
myNewDate = &calculatecalcul_date(myDate;40;'D')                     /* addajouter 40 Daysjours toà myDate

myNewTime = &calculatecalcul_timeheure(myTime;1;'H')                     /* addajouter 1 Hoursheure toà myTime
myNewTime = &calculatecalcul_timeheure(myTime;-6;'M')                    /* substractsoustraire 6 Minutesminutes toà myTime
myNewTime = &calculatecalcul_timeheure(myTime;40;'S')                    /* addajouter 40 Secondssecondes toà myTime

myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;1;'Y ')         /* addajouter 1 Yearannée toà myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;-6;'M ')        /* substractsoustraire 6 Monthsmois à myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;40;'D ')        /* addajouter 40 Daysjours toà myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;1;'H ')         /* addajouter 1 Hoursheure toà myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;-6;'MI')        /* substractsoustraire 6 Minutesminutes toà myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;40;'S ')        /* addajouter 40 Secondssecondes toà myTimestamp
myNewTimestamp = &calculatecalcul_tmstimestp(myTimestamp;-30;'MS')       /* substractsubstraire 30 Secondssecondes toà myTimestamp

2 -

...

Calculer des intervales entre des types dates, time

...

et timestamp

...


Afin de calculer des intervales entre des variables de type Date, Time and Timestamp, on utilisera les fonctions prédéfinies suivantes :

  • &Ecart_Dates
  • &Ecart_Heures
  • &Ecart_Timestps

...

In order to calculate intervals between Dates, Times and Timestamps, we can use the following functions

  • &Date_Interval
  • &Time_Interval
  • &Timestamp_Interval


Bloc de code
/* ___ DeclarationsDéclarations _____________________________________________________________________
date        myDate1
date        myDate2
time_t        myTime1
time_t        myTime2
timestamp   myTimestamp1
timestamp   myTimestamp2
num_e(9,0)  myInterval1
num_e(9,0)  myInterval2
num_e(15,0) myInterval3

/* ___ Code _____________________________________________________________________________
myInterval1 = &dateecart_intervaldates(myDate1;myDate2)                   /* numbernombre ofde daysjours betweenentre myDate1 andet myDate2 (canla bevaleur apeut negativeêtre numbernégative ifsi myDate1 est ifplus greatergrand thanque myDate2)
myInterval2 = &timeecart_intervalheures(myTime1;myTime2)                  /* numbernombre ofde secondssecondes betweenentre myTime1 andet myTime2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTime1 ifest plus greatergrand thanque myTime2)

myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'Y ')   /* numbernumbre of years betweend'années entre myTimestamp1 andet myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 est ifplus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'M ')   /* number of months between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 est ifplus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'D ')   /* number of days between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 ifest plus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'H ')   /* number of hours between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 ifest plus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MI')   /* number of minutes between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 ifest plus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'S ')   /* number of seconds between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 est ifplus greatergrand thanque myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MS')   /* number of microseconds between myTimestamp1 and myTimestamp2 (canla bevaleur apeut negativeêtre numbernégative ifsi myTimestamp1 est ifplus greatergrand thanque myTimestamp2)


...

Image

1 -

...

Transformer une variable alpha en variable

...

image

...

Si une variable de type image contient du texte, il est possible de transformer le contenu d'une variable de type alphanumérique en type image de la façon suivante

...

If an image variable should contains a text, it is possible to transform the content of an alpha variable to an image variable in the following way

Bloc de code
/* ___ DeclarationsDéclarations _____________________________________________________________________
alpha( 100) fileAlias
alpha(  10) fileMode
alpha(5000) myAlpha
image       myImage
num_bin_4   nb4ReturnCode

/* ___ Code _____________________________________________________________________________
myAlpha   = 'my text to be transformed to an image variable (2205)
fileAlias = 'myTransformation'
fileMode  = 'w'

loadcharger_dll   'VATOOLBX.DLL'
callappeler_dll   'VATOOLBX.DLL' 'VaToolBxOpenFile' fileAlias myImage fileMode nb4ReturnCode
callappeler_dll   'VATOOLBX.DLL' 'VaToolBxWriteString' fileAlias myAlpha nb4ReturnCode
callappeler_dll   'VATOOLBX.DLL' 'VaToolBxCloseFile' fileAlias nb4ReturnCode
unloaddecharger_dll 'VATOOLBX.DLL'

/* la thevariable myImage variablecontient nowle containstexte theinitialement alphacontenu textdans fromla thevariable myAlpha variable.

2 -

...

Transformer une variable image en variable

...

alpha

...


Si une variable de type Image contient seulement du texte, il est possible de transformer la variable de type Image en type alpha de la façon suivante

...

If an Image variable contains only text, it is possible to transform the Image variable to an alpha variable with the following code :

Bloc de code
/* ___ DeclarationsDéclarations _____________________________________________________________________
alpha( 100) fileAlias
alpha(  10) fileMode
num_bin_4   fileSize
alpha(5000) myAlpha
image       myImage

num_bin_4   nb4ReturnCode

/* ___ Code _____________________________________________________________________________
fileAlias = 'myTransformation'
fileMode  = 't'
fileSize  = 5000  

loadcharger_dll    'VATOOLBX.DLL' 
callappeler_dll    'VATOOLBX.DLL' 'VaToolBxOpenFile' fileAlias myImage fileMode nb4ReturnCode 
callappeler_dll    'VATOOLBX.DLL' 'VaToolBxWriteString' fileAlias myAlpha nb4ReturnCode 
callappeler_dll    'VATOOLBX.DLL' 'VaToolBxReadFile' fileAlias myAlpha fileSize nb4ReturnCode 
callappeler_dll    'VATOOLBX.DLL' 'VaToolBxCloseFile' fileAlias nb4ReturnCode
unloaddecharger_dll 'VATOOLBX.DLL'

/* la thevariable myAlpha variablecontient nowle containstexte the alpha textinitialement fromcontenu thedans myImagela variable myImage.
/* thela variable fileSize containscontient thele realnombre numberde ofcaractères characterslu fromde thela imagevariable variablemyImage.

...


...

Listes

1 -

...

Déclarations

Une liste peut être declarée avec des variables , ou en référence à une entité logique , ou en reference to à une autre liste , ou encore une combination de ces éléments

...

A list can be declared with variables , or in reference to a logical entity , or in reference to another list , or a combination of those elements .

Bloc de code
/* ___ ListsDéclarations de declarationsli _______________________________________________________________ 
LISTLISTE LST_EXAMPLE    ELT_ONE ELT_TWO ELT_2205											/* définir definingune aliste listavec withdes singleéléments elementssimples defineddéfinis previouslyauparavant, ici les herevariables ELT_ONE, ELT_TWO andet ELT_2205 variables
LISTLISTE LST_ART_ALC_2  *REF_LDMMLD(HL_ART_ALCOOL)												/* definingdéfinir aune listliste withavec alltoutes theles propertiespropriétés ofde thel'entité HL_ART_ALCOOL ldm
LISTLISTE LST_ART_ALC_3  *REF_LDMMLD(HL_ART_ALCOOL) *REF_LDMMLD(HL_ART_LANGUE) 					/* definingdéfinir aune listliste withavec alltoutes theles propertiespropriétés ofdes theentités HL_ART_ALCOOL ldm andet the HL_ART_LANGUE ldm
LISTLISTE LST_ART_ALC_4  *REF_LDMMLD(HL_ART_ALCOOL) *REF_LDMMLD(HL_ART_LANGUE) w_COD_ARTICLE_1		/* definingdéfinir aune listliste withavec alltoutes theles propertiespropriétés ofdes theentités HL_ART_ALCOOL ldmet and the HL_ART_LANGUE, ldmplus plusla thevariable w_COD_ARTICLE_1 variable
LISTLISTE LST_ART_ALC_5  *REF_L(LST_ART_ALC_4) ELT_2205		                           		/* definingdéfinir une aliste listavec withtoutes allles thepropiétés propertiesde ofla theliste LST_ART_ALC_4, listplus plusla thevariable ELT_2205 variable

2 -

...

Utilisation des listes

1 -

...

A list is a structured object in memory with columns, it's like a table but in memory.

...

Ajouter des éléments

Une liste est un objet mémoire structuré composé de colonnes, c'est similaire à une table, mais en mémoire.

Pour insérer des données dans une liste, il suffit de frenseigner la valeur des variables colonnes de la liste, puis d'ajouter un élément à la list avec l'ordre L4G INSERER_ELT

Les éléments sont par défaut ajoutés à la fin de la liste (*FIN), mais on peut aussi les ajouter ...

  • au début de la liste (INSERER_ELT *DEBUT)
  • à la fin de la liste (INSERER_ELT *FIN)
  • avant l'élément courant (INSERER_ELT *AVANT)
  • après l'élément courant (INSERER_ELT *APRES)
  • trié suivant une (ou plusieurs) colonne(s) (INSERER_ELT *TRI

...

Elements are by default added at the end of the list (*END), but the also can be added 

  • at the beginning of the list (INSERT_ELT *BEGIN)
  • at the end of the list (INSERT_ELT *END)
  • before the current element (INSERT_ELT *BEFORE)
  • after the current element (INSERT_ELT *AFTER)
  • in the sort order of one (or more) column(s) (INSERT_ELT *SORT(...) )

By default, lines inserted in the list are not considered as modified, but we can tag them as modified when inserted if we want to retrieve later the modified elements. To do this, we can add the *CHANGE tag during the insertionPar default, les lignes insérées dans la liste ne sont pas considérées comme modifiées, mais on peut les indiquer comme modifées au momenet de l'insertion si on veut retrouver plus tard ces éléments modifiés. Pour ce faire, il suffit d'ajouter *MODIF à l'ordre INSERER_ELT.

Bloc de code
/* ___ Listes Lists- usage ___________________exemples d'utilisation ____________________________________________
ELT_ONE  = 1
ELT_TWO  = 2
ELT_2205 = 2205
INSERTINSERER_ELT LST_EXAMPLE 

INSERTINSERER_ELT LST_EXAMPLE *BEGINDEBUT										/* topour insertinsérer anun elementélément inau thedébut listde at the start of the list 
INSERTla liste
INSERER_ELT LST_EXAMPLE *ENDFIN											/* topour insertinsérer anun elementélément inà thela listfin atde thela end of the list (as it is the default value, it can be omitted)
INSERTliste (comme c'est la valeur par défaut *FIN peut être omis)
INSERER_ELT LST_EXAMPLE *BEFOREAVANT  									/* topour insertinsérer anun elementélément indans thela listliste beforeavant the current element
INSERTl'élément courant
INSERER_ELT LST_EXAMPLE *AFTERAPRES  										/* topour insertinsérer anun elementélément indans the listla afterliste theaprès currentl'élément elementcourant
INSERTINSERER_ELT LST_EXAMPLE *SORTTRI(ELT_2205 *DESC, ELT_TWO *ASC)			/* topour insertinsérer anun elementélément indans thela listliste sortedtrié bypar ELT_2205 descendingdescendant, thenpuis ELT_TWO ascendingascendand (*ASC isest defaultla sovaleur itdéfaut, canpeut beêtre omittedomis)

INSERTINSERER_ELT LST_EXAMPLE *CHANGEMODIF										/* to insert an element AND make it a changed element (could be retrieved by a READ pour insérer un élément dans la liste ET en faire initialement un élément modifié (qui pourra être relu par LECTURE_LST LST_EXAMPLE *CHANGEMODIF ... END_READ_LST)

2 -

...

Parcourir une liste

Afin de parcourir une liste, on pourra utiliser la boucle LECTURE_LST ... FIN_LECTURE_LST

Dans la boucle de parcours d'une liste on est positionné sur un élément et on peut modifier (avec MODIFIER_ELT) ou supprimer (avec SUPPRIMER_ELT) l'élément courant.

In order to parse a list , we can use the READ_LST loop. 

Inside a parsing loop we are on one element and we can modify it (with CHANGE_ELT) or delete it (with DELETE_ELT)

Bloc de code
/* ___ ListsListe - usageutilisations _______________________________________________________________
READ 
LECTURE_LST LST_EXAMPLE 

  /* ELT_ONE iscontient filledla withvaleur thede valuela ofpremière theligne firstde linela onliste the(pour firstla iteration of the list, same for colonne ELT_ONE), de même pour ELT_TWO andet ELT_2205
  ...
  IFSI ...
    DELETESUPPRIMER_ELT LST_EXAMPLE						/* weon canpeut deletesupprimer the current element l'élément courant
  ENDFIB
  IFSI ...
    ELT_ONE = ELT_ONE + 1
    CHANGEMODIFIER_ELT LST_EXAMPLE						/* weon canpeut changemodifier theles valuesvaleurs ofde thel'élément currentcourant elementen if we modify onemodifiant une (orou moreplusieurs) ofdes colonnes hisqui columns
le composent     CHANGE
	MODIFIER_ELT LST_EXAMPLE	*SELECT				/* whenen changingmodifiant anun elementélément weon canpeut addajouter thel'attribut tagSELECT SELECTED or UNSELECTED to the elementou DESELECT 
  ENDFIN 
ENDFIN_READLECTURE_LST

/* ___ WePour canune parseliste forgraphique, aon graphicalpeut listparcourir theles elementséléments selectedsélectionnés by the userpar l'utilisateur ______
READLECTURE_LST LST_GRAPHICAL *SELECT
	... 
ENDFIN_READLECTURE_LST  

/* ___ We canPour parseune forliste agraphique, graphicalon listpeut theparcourir elementsles modifiedéléments bymodifiés thepar userl'utilisateur orou bypar aprogramme programsi if it sets the *CHANGE tag during the l'attribut *MODIF a été spécifié au moment de l'insertion ___
READLECTURE_LST LST_GRAPHICAL *CHANGEMODIF
	...
ENDFIN_READLECTURE_LST

On peut aussi utiliser une boucle manuelle avec LIRE_P_ELT (lire le premier élément) et LIRE_AV_ELT (lire l'élément suivant).

On peut également utililser LIRE_D_ELT (lire le denier élément) and LIRE_AR_ELT (lire l'élément précédentWe can also use more manual loop with READ_F_ELT (read first element) and READ_NX_ELT (read next element).We can also use READ_L_ELT (read last element) and READ_PR_ELT (read previous element).

Bloc de code
/* ___ Lists usage _______________________________________________________________
READ_F_ELT LST_EXAMPLE 							/* we try to read the first element of the list (if it exists)
DO_WHILE &CODE_LST(LST_EXAMPLE) = *NORMAL		/* did the last operation on the list end successfully ?
  ...
  READ_NX_ELT LST_EXAMPLE						/* try to read the next element of the list
REDO

READ_L_ELT LST_EXAMPLE 							/* we try to read the last element of the list (if it exists)
DO_WHILE &CODE_LST(LST_EXAMPLE) = *NORMAL		/* did the last operation on the list end successfully ?
  ...
  READ_PR_ELT LST_EXAMPLE						/* try to read the next element of the list
REDO

...