help needed

Paul Mulroney pmulroney at logicaldevelopments.com.au
Tue Sep 15 20:43:11 EDT 2020


Hi Grant,

We do something similar in our system - we setup a list with all text columns and then merge the data into that list.  Here's some code that does that:

Create a list with character cols for each column in the original list:

> Begin reversible block
> 	Set current list plExportList
> End reversible block
> Calculate v as plExportList.$colcount()
> Do vlExport.$define()
> For v from 1 to plExportList.$colcount() step 1
> 	Do vlExport.$cols.$add(plExportList.$cols.[v].$name,kCharacter,kSimplechar)     
> End For

Copy the data into the newly created list:

> For each line in list from 1 to #LN step 1     ;; plExportList
> 	Do vlExport.$add()     
> 	For v from 1 to plExportList.$colcount() step 1
> 		Calculate vlExport.[vlExport.$linecount].C[v] as plExportList.[plExportList.$line].[v]
> 	End For
> End For

Add a line at the start of the list, and make it contain the name of the column as the heading:

> Calculate vlExport.$line as 1
> Do vlExport.$addbefore(1)
> For v from 1 to plExportList.$colcount() step 1
> 	Calculate vsName as plExportList.$cols.[v].$name
> 	Calculate vlExport(v,1) as vsName
> End For

Hope this helps!

regards,
Paul.


> On 16 Sep 2020, at 5:10 am, Bookit Enterprises <bookit.grant at gmail.com> wrote:
> 
> I am doing some code to do a data dump from Studio, for one of my clients who is moving to another vendor.
> 
> I have the following code, which works just fine, gathers all the data, puts it in a spreadsheet named after the file format it came from:
> 
> Do $files.$makelist($ref.$name) Returns iFilesList     ;; gather existing slots
> Do iFilesList.$redefine(iFileName)
> 
> Calculate iPath as sys(11)
> Calculate iPath as mid(iPath,1,pos('books',iPath)-1)     ;; path to my df storage folder
> 
> Set current list iFilesList
> For each line in list from 1 to #LN step 1     ;; get all the data from each slot
> Load from list
> If iFileName='FGlobalVariables'|iFileName='#APPLICATION'|iFileName='#SLOTS’ ; FGlobalVariables  is memory only
> Else
> Set main file {[iFileName]}
> Set read/write files {[iFileName]}
> Clear main file
> Set current list iDataTransferList
> Define list {[iFileName]}
> Repeat
>    Add line to list
>   Next 
> Until flag false
> Set print or export file name {[con(iPath,iFileName)]}
> Prepare for export to file {Tab-delimited}
> Export data iDataTransferList
> Set current list iFilesList
> End If
> End For
> Close data file
> 
> However, I would like to include the field names as the first line of the exported list, which is essentially the list definition.
> Because the list is defined by the field names, some of which are numeric, or boolean, so I think I need to export the field names first, then do the ‘Export data’ command.  But I can’t seem to wrap my old brain around how to do it.
> 
> Any ideas you could help me with?
> 
> Grant Thiessen
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 




  <https://www.logicaldevelopments.com.au/>	Paul W Mulroney
Logical Developments
Customised Software Solutions
Ph: 08 9458 3889
 	We Don't Do Simple Pty Ltd
trading as
Logical Developments
ACN 161 009 374
 	  <https://www.facebook.com/logicaldevelopmentswa/>   <https://twitter.com/WeDontDoSimple>   <https://www.linkedin.com/company/logicaldevelopments/>   <https://www.youtube.com/channel/UCPldVVgWR05WX3cVrR5WUQw>



More information about the omnisdev-en mailing list