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.

...

French version / version Française

A frenche french version of this FAQ exists à the following address : https://portal.hardis-group.com/x/gYjWIg

...

Bloc de code
/* ___ Declarations _____________________________________________________________________
ALPHA( 10) wLeft 
ALPHA( 10) wRight
ALPHA( 20) wText1 
ALPHA( 20) wText2 
ALPHA( 20) wText3 

/* ___ Code _____________________________________________________________________________
wLeft  = 'Hello'
wRight = 'World' 
wText1 = wLeft //  wRight						/* wText1 = 'Hello     World     '
wText2 = wLeft /// wRight						/* wText2 = 'HelloWorld          '
wText3 = wLeft /// ' ' // wRight				/* wText3 = 'Hello World         '

...

3 - Calculate the length of a string

...


In order to split a string into different strings (to a list of strings in reality) according to a separatorcalculate the length of a string, you simply have to use the  SPLIT_STRING instruction :the &LONGUEUR_CHAINE predefined function : 

Bloc de code
/* ___ DeclarationsDéclarations _____________________________________________________________________
alpha(num_bin_2  50) elementDay
list        lst_days elementDay stringLength
alpha(1000100)  myDaysmyString

/* ___ Code _____________________________________________________________________________
myDaysmyString      = 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday'
split_string myDays ';' lst_days
	/* the list "lst_days" will contain 7 elements : 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'

3 - How to replace a part of a string

alpha beta'  
stringLength  = &longueur_chaine(myString)
    /* stringLength value is 10

2 - How to split a string according to a separator

In order to split a string into different strings (to a list of strings in reality) according to a separatorIn order to replace a substring in a string, you simply have to use the SCANSPLIT_REPLACE instruction STRING instruction :

Bloc de code
/* ___ Declarations _____________________________________________________________________
alpha(1000  50) myDays
alpha(1000) myDaysModified
alpha(  56) mySearchString
alpha(  78) myReplacementStringelementDay
list        lst_days elementDay
alpha(1000) myDays

/* ___ Code _____________________________________________________________________________
myDays              = 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday'
mySearchStringsplit_string myDays     = ';'
myReplacementString = ' , '
myDaysModified      = *blank
scan_replace myDays mySearchString myReplacementString myDaysModified lst_days
	/* the string myDaysModifiedlist "lst_days" will contain 7 elements : 'Sunday ', 'Monday ', 'Tuesday ', 'Wednesday ', 'Thursday ', 'Friday ', 'Saturday'

...

3 - How to

...

replace a part of a string

...

In order to

...

In order to add a "return" to an alphanumerical variable, you should create a "CR" (carriage return) + "LF" (line feed) string and add it to your alphanumerical variable.replace a substring in a string, you simply have to use the  SCAN_REPLACE  instruction :

Bloc de code
/* ___ Declarations _____________________________________________________________________
ALPHAalpha(  11000) wCR myDays
ALPHAalpha(  11000) wLF myDaysModified
ALPHAalpha(  256) wCRLF mySearchString
ALPHAalpha(100  78) wText myReplacementString

/* ___ Code _____________________________________________________________________________
wCR = &CHAR_CONVERSION('0D') 
wLF = &CHAR_CONVERSION('0A') 
wCRLF = wCR // wLF 
wText = 'Hello' /// wCRLF /// 'world'

z_display = wText 

The multi-line property of the text object should be checked if you want to see the line return.

Image Removed

Date, Time and Timestamp

...

myDays              = 'Sunday;Monday;Tuesday;Wednesday;Thursday;Friday;Saturday'
mySearchString      = ';'
myReplacementString = ' , '
myDaysModified      = *blank
scan_replace myDays mySearchString myReplacementString myDaysModified
	/* the string myDaysModified will contain 'Sunday , Monday , Tuesday , Wednesday , Thursday , Friday , Saturday'

4 - How to add a "carriage return" in a string in order to have a return to the line in a screen.

In order to add a "return" to an alphanumerical variable, you should create a "CR" (carriage return) + "LF" (line feed) string and add it to your alphanumerical variable.

Bloc de code
/* ___ Declarations _____________________________________________________________________
ALPHA(  1) wCR 
ALPHA(  1) wLF 
ALPHA(  2) wCRLF 
ALPHA(100) wText 

/* ___ Code _____________________________________________________________________________
wCR = &CHAR_CONVERSION('0D') 
wLF = &CHAR_CONVERSION('0A') 
wCRLF = wCR // wLF 
wText = 'Hello' /// wCRLF /// 'world'

z_display = wText 

The multi-line property of the text object should be checked if you want to see the line return.

Image Added


...

Date, Time and Timestamp

1 - Calculating dates, time and timestamp values

In order to calculate Date, Time and Timestamps, we can use the following functions

  • &Calculate_Date
  • &Calculate_Time
  • &Calculate_Timestamp
Bloc de code
/* ___ Declarations _____________________________________________________________________
date        myDate
date        myNewDate
time_t      MyTime
time_t      MyNewTime
timestamp   MyTimestamp
timestamp   MyNewTimestamp

/* ___ Code _____________________________________________________________________________
myNewDate = &calculate_date(myDate;1;'Y')                   /* add 1 Year to myDate
myNewDate = &calculate_date(myDate;-6;'M')                  /* substract 6 Months to myDate
myNewDate = &calculate_date(myDate;40;'D')                  /* add 40 Days to myDate

myNewTime = &calculate_time(myTime;1;'H')                   /* add 1 Hours to myTime
myNewTime = &calculate_time(myTime;-6;'M')                  /* substract 6 Minutes to myTime
myNewTime = &calculate_time(myTime;40;'S')                  /* add 40 Seconds to myTime

myNewTimestamp = &calculate_tms(myTimestamp;1;'Y ')         /* add 1 Year to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-6;'M ')        /* substract 6 Months myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'D ')        /* add 40 Days to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;1;'H ')         /* add 1 Hours to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-6;'MI')        /* substract 6 Minutes to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'S ')        /* add 40 Seconds to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-30;'MS')       /* substract 30 Seconds to myTimestamp

2 - Calculating intervals between dates, time and timestamp values

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

  • &CalculateDate_DateInterval
  • &CalculateTime_TimeInterval
  • &CalculateTimestamp_TimestampInterval
Bloc de code
/* ___ Declarations _____________________________________________________________________
date        myDatemyDate1
date        myNewDatemyDate2
time_t      MyTimemyTime1
time_t      MyNewTimemyTime2
timestamp   MyTimestampmyTimestamp1
timestamp   MyNewTimestampmyTimestamp2
num_e(9,0)  myInterval1
num_e(9,0)  myInterval2
num_e(15,0) myInterval3

/* ___ Code _____________________________________________________________________________
myNewDatemyInterval1 = &calculatedate_dateinterval(myDate;1;'Y'myDate1;myDate2)                   /* number addof 1days Yearbetween tomyDate1 myDate
myNewDateand =myDate2 &calculate_date(myDate;-6;'M')             (can be a negative number if myDate1 if greater than myDate2)
myInterval2 = &time_interval(myTime1;myTime2)     /* substract 6 Months to myDate
myNewDate = &calculate_date(myDate;40;'D')    /* number of seconds between myTime1 and myTime2 (can be a negative number if /*myTime1 addif 40greater Days to myDatethan myTime2)

myNewTimemyInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;1myTimestamp2;'HY ')   /* number of years between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if /*greater add 1 Hours to myTime
myNewTimethan myTimestamp2)
myInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;-6myTimestamp2;'M ')   /* number of months between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 /*if substract 6 Minutes to myTime
myNewTimegreater than myTimestamp2)
myInterval3 = &calculatetms_timeinterval(myTimemyTimestamp1;40myTimestamp2;'SD ')   /* number of days between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 /*if addgreater 40 Seconds to myTime

myNewTimestampthan myTimestamp2)
myInterval3 = &calculatetms_tmsinterval(myTimestampmyTimestamp1;1myTimestamp2;'YH ')   /* number of hours between myTimestamp1 and myTimestamp2 (can be a negative number /*if addmyTimestamp1 1if Yeargreater tothan myTimestampmyTimestamp2)
myNewTimestampmyInterval3 = &calculatetms_tmsinterval(myTimestampmyTimestamp1;-6myTimestamp2;'M MI')        /* substractnumber 6 Months myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'D ')        /* add 40 Days to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;1;'H ')         /* add 1 Hours to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-6;'MI')        /* substract 6 Minutes to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;40;'S ')        /* add 40 Seconds to myTimestamp
myNewTimestamp = &calculate_tms(myTimestamp;-30;'MS')       /* substract 30 Seconds to myTimestamp

2 - Calculating intervals between dates, time and timestamp values

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

of minutes between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'S ')   /* number of seconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MS')   /* number of microseconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)

3 - Extract informations from a Date variable

In order to extract informations from a Date variable, we can use the following functions

  • &Date_To_Year
  • &Date_To_Month
  • &Date_To_Day
  • &Date_To_Num
  • &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
myDate
num_e(94,0)  myInterval1myYear
num_e(92,0)  myInterval2myMonth
num_e(152,0)  myInterval3myDay

/* ___ Code _____________________________________________________________________________
myInterval1 = &date_interval(myDate1;myDate2)                /* number of days between myDate1 and myDate2 (can be a negative number if myDate1 if greater than myDate2)
myInterval2 = &time_interval(myTime1;myTime2)                /* number of seconds between myTime1 and myTime2 (can be a negative number if myTime1 if greater than myTime2)

myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'Y ')   /* number of years between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'M ')____________________
myYear      = &date_to_year(myDate)                            /* numberextract ofthe monthsyear betweenfrom myTimestamp1the anddate myTimestamp2myDate (canyear will be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3in format CCYY (century + year)  
myMonth     = &tmsdate_to_interval(myTimestamp1;myTimestamp2;'D 'month(myDate)   /* number of days between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'H ')   /* number of hours between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MI')   /* number of minutes between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'S ')   /* number of seconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)
myInterval3 = &tms_interval(myTimestamp1;myTimestamp2;'MS')   /* number of microseconds between myTimestamp1 and myTimestamp2 (can be a negative number if myTimestamp1 if greater than myTimestamp2)

 extract the month from the date myDate
myDay       = &date_to_day(myDate)                             /* extract the day from the date myDate
myDateNum   = &date_to_num(myDate)                             /* convert the date myDate to a numerical date (YYYYMMDD format)


...

Image

1 - Transforming an alpha variable to an image variable

...

Bloc de code
/* ___ Declarations _____________________________________________________________________
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

load_dll   'VATOOLBX.DLL'
call_dll   'VATOOLBX.DLL' 'VaToolBxOpenFile' fileAlias myImage fileMode nb4ReturnCode
call_dll   'VATOOLBX.DLL' 'VaToolBxWriteString' fileAlias myAlpha nb4ReturnCode
call_dll   'VATOOLBX.DLL' 'VaToolBxReadFile' fileAlias myAlpha fileSize nb4ReturnCode
call_dll   'VATOOLBX.DLL' 'VaToolBxCloseFile' fileAlias nb4ReturnCode
unload_dll 'VATOOLBX.DLL'

/* the myAlpha variable now contains the alpha text from the myImage variable.
/* the fileSize contains the real number of characters from the image variable.

...