Exporting Messages

The into directive can be used within the info and open command objects, which allows the export of CXIO messages into different message formats and protocols.

In the example below, the info test contains an item named "hello" with the value of "world". The into directive has a value of "disk" meaning that the message will be exported to the local filesystem. A path is specified, which tells the exporter to where to save the file to.

info test
     
     hello: "world"

     into disk
         
          path "c:\cxio\test.cxio"

     ends

ends                  

Executing the above command will result the following test.cxio file being created.

info test
     
     hello: "world"

ends                  

Specifying Filenames

The name decorator can be applied against info, part or body to set export filenames.

In the example below, the info command object has a name decorator set to "text.cxio". Within the into directive, the path is set to the folder path of "c:\cxio\".

info test name "test.cxio"
     
     hello: "world"

     into disk
         
          path "c:\cxio\"

     ends

ends                  

Executing the above command would also result the same test.cxio file being created.

info test
     
     hello: "world"

ends                  

Splitting Messages

Message content can be split into multiple files by specifying the name decorator against the body directive, as shown in the example below.

info petstore
   
     from petsandco
        
     body name "cat.cxio"     
          pet: "cat"
          sound: "meow"
     ends

     body name "dog.cxio"    
          pet: "dog"
          sound: "woof"
     ends

     into disk
         
          path "c:\cxio\test\"

          chop body

     ends

ends                  

Executing the previous command will result in two files named "cat.cxio" and "dog.cxio" being created within "c:\cxio\test\". The chop directive set to body means the exporter will split the message content per body.

info petstore
   
     from petsandco   
   
     body name "cat.cxio"     
          pet: "cat"
          sound: "meow"
     ends

ends
cat.cxio
info petstore
   
     from petsandco   
   
     body name "dog.cxio"    
          pet: "dog"
          sound: "woof"
     ends

ends
                 
dog.cxio

Splitting Multipart Messages

Multipart content can be split into multiple files by specifying the name decorator against the part directive, as shown in the example below.

info invoice
     
     from tradesuppliers
     
     part as batch01 name "invoices_usd.cxio"
     
     	  recv accounts_dept_us
     
          body as "invoice01"
               item total          as 943.37  decimal
               item currency       as "USD"   char(3)
               line tax               
                    item tax       as 157.23  decimal
                    item rate      as 1.20    decimal                  
               ends 
          ends
          
          body as "invoice02"
               item total          as 70.34   decimal
               item currency       as "USD"   char(3)               
               line tax               
                    item tax       as 11.72   decimal
                    item rate      as 1.20    decimal                
               ends 
          ends
     
     ends
     
     part as batch02 name "invoices_eur.cxio"
     
     	  recv accounts_dept_eu     
     
          body as "invoice03"
               item total          as 511.34  decimal
               item currency       as "EUR"   char(3)               
               line tax               
                    item tax       as 85.22   decimal
                    item rate      as 1.20    decimal                  
               ends 
          ends
     
     ends     
     
     into disk
                    
          path "c:\cxio\test\"
          
          chop part
          
     ends
          
ends              

Executing the previous command will result in two files named "invoices_usd.cxio" and "invoices_eur.cxio" being created. The chop directive set to part means that the export will split the message content per part.

info invoice
   
     from tradesuppliers   
   
     part as batch01 name "invoices_usd.cxio"
     
          recv accounts_dept_us
     
          body as "invoice01"
               item total          as 943.37  decimal
               item currency       as "USD"   char(3)               
               line tax               
                    item tax       as 157.23  decimal
                    item rate      as 1.20    decimal                  
               ends 
          ends
          
          body as "invoice02"
               item total          as 70.34   decimal
               item currency       as "USD"   char(3)               
               line tax               
                    item tax       as 11.72   decimal
                    item rate      as 1.20    decimal                
               ends 
          ends
     
     ends

ends
invoices_usd.cxio
info invoice

     from tradesuppliers
   
     part as batch02 name "invoices_eur.cxio"
     
          recv accounts_dept_eu
     
          body as "invoice03"
               item total          as 511.34  decimal
               item currency       as "EUR"   char(3)                   
               line tax               
                    item tax       as 85.22   decimal
                    item rate      as 1.20    decimal                  
               ends 
          ends
     
     ends    

ends
invoices_eur.cxio

Introducing Transports

In previous examples, we have used the path directive to specify the output location for message content. Path is a special directive which sets the underlying path property against the named transport, in this case disk.

It is possible to override the default properties of the transport using with or meta shorthand (@) values as shown below.

info invoice name "invoice.cxio"

     total: 102.43
     
     into disk
         
          @path: "c:\cxio\"
          @overwrite: false
          
     ends

ends        

We can define our own custom transports with default settings using the comm directive, as shown below.

comm disk_protected base disk

     desc "my protected disk"
     
     with path as "c:\cxio\"
     with overwrite as false

ends        

Once a custom transport has been declared, it is now possible to make use of it as shown below.

info invoice name "invoice.cxio"

     total: 102.43
     
     into disk_protected

ends        

Custom transports can be removed from memory by using the drop directive.

drop comm disk_protected