libsim  Versione6.3.0

◆ csv_record_addfield_char()

subroutine, private file_utilities::csv_record_addfield_char ( type(csv_record), intent(inout)  this,
character(len=*), intent(in)  field,
logical, intent(in), optional  force_quote 
)
private

Add a field from a CHARACTER variable to the csv record this.

The field will be quoted if necessary.

Da fare:
Improve the trailing blank quoting.
Parametri
[in,out]thisobject where to add field
[in]fieldfield to be added
[in]force_quoteif provided and .TRUE. , the field will be quoted even if not necessary

Definizione alla linea 577 del file file_utilities.F90.

577 CHARACTER(len=this%cursor) :: csv_record_getrecord
578 
579 csv_record_getrecord = TRANSFER(this%record(1:this%cursor), csv_record_getrecord)
580 IF (present(nfield)) nfield = this%nfield
581 
582 END FUNCTION csv_record_getrecord
583 
584 
590 SUBROUTINE csv_record_getfield_char(this, field, flen, ier)
591 TYPE(csv_record),INTENT(INOUT) :: this
592 CHARACTER(len=*),INTENT(OUT),OPTIONAL :: field !< contents of the field, if not provided, the field pointer is increased only; if the variable is not long enough, a warning is printed and the part that fits is returned;
593 
594 INTEGER,INTENT(OUT),OPTIONAL :: flen
595 INTEGER,INTENT(OUT),OPTIONAL :: ier
596 
597 LOGICAL :: inquote, inpre, inpost, firstquote
598 INTEGER :: i, ocursor, ofcursor
599 
600 ! check end of record
601 IF (csv_record_end(this)) THEN
602  IF (PRESENT(field)) field = cmiss
603  IF (PRESENT(ier))THEN
604  ier = 2
605  ELSE
606  CALL l4f_log(l4f_error, &
607  'in csv_record_getfield, attempt to read past end of record')
608  CALL raise_error()
609  ENDIF
610  RETURN
611 ENDIF
612 ! start decoding
613 IF (PRESENT(field)) field = ''
614 IF (PRESENT(ier)) ier = 0
615 ocursor = 0
616 ofcursor = 0
617 inquote = .FALSE.
618 inpre = .TRUE.
619 inpost = .FALSE.
620 firstquote = .FALSE.
621 
622 DO i = this%cursor+1, SIZE(this%record)
623  IF (inpre) THEN ! sono nel preludio, butto via gli spazi
624  IF (is_space_b(this%record(i))) THEN
625  CYCLE
626  ELSE
627  inpre = .FALSE.
628  ENDIF

Generated with Doxygen.