Here is the full list of code with the procedures. 
Code: Select all
Global Counter.l
Structure EmailData
  FullName.s
  Eid.s
  Size.s
  E_Server.s
  Marsha.s
  Domain.s
  Dept.s
EndStructure
Global Dim Exchange.EmailData(1000)
Procedure Get_Data(MailBoxFile.s)
  Master_Marsha.s = "XXXX1"
  OpenFile(1,MailBoxFile)
  Counter=1
  Header$=ReadString(1)
  Line$ = ReadString(1) 
  Repeat
    LastName$ = StringField(Line$, 1, ",")
    Last_Name$ = Right(LastName$,Len(LastName$)-1) ; remove Quotes at the start of the name
    
    FirstName$ =StringField(Line$, 2, ",")
    First_Name$ = Left(FirstName$,Len(FirstName$)-1); remove Quotes at the end of the name
    
    Name$ = Last_Name$+", "+First_Name$ ; Put Name back together with a Common
    
    EID$ =StringField(Line$, 3, ",")
    EID$ = Mid(EID$,2,Len(EID$)-2)
    
    Size$=StringField(Line$, 4, ",")
    MG_Size.f = ValF(Size$) /1024
    
    
    Server$=StringField(Line$, 5, ",")
    Server$ = Mid(Server$,2,Len(Server$)-2)
    
    Marsh$=StringField(Line$, 6, ",")
    Marsh$ = Mid(Marsh$,2,Len(Marsh$)-2)
    
    Domain$=StringField(Line$, 7, ",")
    Domain$ = Mid(Domain$,2,Len(Domain$)-2)
    
    Department$=StringField(Line$, 8, ",")
    Department$ = Mid(Department$,2,Len(Department$)-2) 
    
    If Marsh$ = Master_Marsha
      Exchange(Counter)\FullName = Name$
      Exchange(Counter)\Eid = EID$
      Exchange(Counter)\Size = StrF(MG_Size,2)
      Exchange(Counter)\E_Server = Server$
      Exchange(Counter)\Marsha = Marsh$
      Exchange(Counter)\Domain = Domain$
      Exchange(Counter)\Dept = Department$
      Counter +1
    EndIf
    Line$ = ReadString(1)
  Until Eof(1) = 1
  CloseFile(1)
EndProcedure
Procedure Write_Data(Mailout.s) 
  
  Sp$=Chr(34)+","+Chr(34)
  Header$ = Chr(34)+"Display Name"+Sp$+"EID"+Sp$+"Mailbox Size Megs"+Sp$+"Server"+Sp$+"Department"+Sp$
  Header$ + "Limit"+Sp$+"Cost"+Chr(34)
  
  OpenFile(2,Mailout)
  WriteStringN(2,Header$)
  
  For loop = 1 To Counter -1
    
    H_Nm$ = Exchange(loop)\FullName
    H_Eid$ = Exchange(loop)\Eid
    H_SZ$ = Exchange(loop)\Size
    H_Srv$ = Exchange(loop)\E_Server
    H_Mar$ = Exchange(loop)\Marsha
    H_Dom$ = Exchange(loop)\Domain
    H_DP$ = Exchange(loop)\Dept
    
    Tmp.f = ValF(H_SZ$)
    If Tmp > 100.5
      Limit$="OVER"
      TotalOver.f = (Tmp-100)*0.024
      Cost$ = StrF(TotalOver,2)
      GrandTotal.f +TotalOver
    Else 
      Limit$="------"
      Cost$ =""
    EndIf
    
    StringLine$ = Chr(34)+H_Nm$+Sp$+H_Eid$+Sp$+H_SZ$+Sp$+H_Srv$+Sp$+H_DP$+Sp$
    StringLine$ + Limit$+Sp$+Cost$+Chr(34)
    WriteStringN(2,StringLine$)
  Next
  WriteStringN(2,"")
  WriteStringN(2,Chr(34)+Sp$+Sp$+Sp$+Sp$+Sp$+"Overage Total"+Sp$+StrF(GrandTotal,2)+Chr(34))
  CloseFile(2)
EndProcedure
Get_Data("c:\test\test.csv") ; Read the data from file This works fine
SortStructuredArray(Exchange(),#PB_Sort_Ascending, OffsetOf(EmailData\FullName), #PB_Sort_String)
Write_Data("c:\test\new.csv") ; Write the data from the array to a new file This also works as long as I don't sort the array. 
  MessageRequester("Completed","Check the Drive") 
The Get _Data and the Write_Data both work fine as long as I don't sort the array. So I fuess that I am loading the data into the structured array in a format that Sort doesn't like. 
Here is the header line and an example of the data that I am reading in.
"DisplayName","EID","MailboxSizeKB","Server","Marsha","Domain","department"
"Smith, Bob","SmithB007",101975,"HOTELEXCH1","XXXX1","ds","12/AAA.00"
Thank you.