Friday, December 19, 2008

FileOperations

static void FileOperations(Args _args)
{
CustTable cust;
CommaIO myfile;
TextBuffer tb;
counter recordCount;
int i;
str fileName;
;

fileName = "C:\\Axapta1.txt"; //<- Alternatively 'Dialog' can be used.
//<- Instead of '.Txt', extensions like
//.Doc, .Xls can also be used.

//Creating new file with write access
myfile = new commaIO(fileName,"w");


//Setting up Record delimiter
myfile.outRecordDelimiter("\r\n");
myfile.outFieldDelimiter(",");


while select cust order by accountnum
{
myfile.write(cust.AccountNum, cust.Name);
}

myfile.write('..........................................');


//To find out record count & write the same end of the file
recordcount = new sysdicttable(tablenum(custTable)).recordCount();
myfile.write("Inserted " + int2str(recordcount) + " Records");

//To close this file
myfile = null; //<- Finalize() method is protected. Hence this alternative ...

//To copy contents of this file into clipboard
tb = new TextBuffer();
tb.fromFile(filename);
tb.toClipboard();
tb = null;

//To delete this file
//winapi::deleteFile(fileName);


//Alternatively To move this file
//winapi::moveFile(fileName, newfileName); // <- Declare 'newfileName'
}



No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...