I'm curious; was the university in Florida Barry University?

Someone I worked with years ago went there as a Pick programmer.


The following code might be helpful


     subroutine ucsv(result,source,status,is.oconv)
*
* Public Domain program for OpenQM by Keith Johnson 2012
*
*  OCONV Converts from attribute and value marks to .CSV format
*        Attribute marks are converted to CR:LF
*  ICONV Converts from .CSV to delimited form
*        If there are no CR:LF sequences, it uses LF
*        If there are no LF characters, it uses attribute marks
*
* Usage: To convert ABC to a .CSV format, use code like
*
*        NEWABC = OCONV(ABC,'UUCSV')
*
*
     result = ''
     status = 0
     crlf = char(13):char(10)
     test = index(source,crlf,1)
*
     begin case
*
* this is OK
        case source = ''
           null
*
* OCONV not OK if there are already CR:LF sequences
        case is.oconv and test
           status = 1
*
* The normal case when generating .CSV data
        case is.oconv
           atts = dcount(source,@am)
           for attr = 1 to atts
              line = source<attr>
CRT 'line = ':line
              vals = dcount(line,@vm)
              part = ''
              for valu = 1 to vals
                 bite = line<1,valu>
                 if part ne '' then part := ','
                 good = @true
                 if index(bite,'"',1) then good = @false
                 if index(bite,' ',1) then good = @false
                 if index(bite,',',1) then good = @false
                 if index(bite,char(10),1) then good = @false
                 if index(bite,char(13),1) then good = @false
                 if not(good) then
                    bite = change(bite,'"','""')
                    bite = '"':bite:'"'
                 end
                 part := bite
              next valu
CRT 'part = ':part
              if result eq ''
                 then result = part
                 else result := crlf:part
           next attr
*
* Cannot have both of these in ICONV file - the rows will change
        case index(source,@am,1) and index(source,char(10),1)
           status = 2
*
* converting from standard .CSV file
        case test
           flag = @false
           mine = change(source,crlf,@am)
           atts = dcount(mine,@am)
           for attr = 1 to atts
              line = mine<attr>
              span = len(line)
              part = ''
              for posn = 1 to span
                 that = line[posn,2]
                 this = that[1,1]
                 begin case
                    case that eq '""' and flag
                       part :=  '"'
                       posn += 1
                    case this eq '"'
                       flag = not(flag)
                    case this eq ',' and not(flag)
                       part := @vm
                    case 1
                       part := this
                 end case
              next posn
              result<-1> = part
           next attr
*
* converting from LF only (or possibly @am) row delimited file
        case 1
           mark = char(10)
           if not(index(source,mark,1)) then
              mark = @am
              if not(index(source,mark,1)) then
                 status = 3
                 return
              end
           end
*
           flag = @false
           atts = dcount(source,mark)
           part = ''
           for attr = 1 to atts
              line = field(source,mark,attr)
              span = len(line)
              for posn = 1 to span
                 that = line[posn,2]
                 this = that[1,1]
                 begin case
                    case that eq '""' and flag
                       part :=  '"'
                       posn += 1
                    case this eq '"' and flag
                       flag = @false
                    case this eq ',' and not(flag)
                       part := @vm
                    case 1
                       part := this
                 end case
              next posn
*
* It is possible to have a linefeed within a field
              if not(flag) then
                 result<-1> = part:char(10)
                 part = ''
              end else
*
* But not an attribute mark when it is the delimiter
* Assume they forgot the last double quote and be nice
                 if mark eq @am then
                    result<-1> = part
                    part = ''
                    flag = @false
                 end
              end
           next attr
     end case
*
     return

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to