Tuesday, May 24, 2011

How to use SUBSTR() function...

static void Segregation(Args _args)
{
    str s,s1;
    int len,j,k;
    ;
    s = "Hello" +  '\n'+ date2str(today() ,123, 2, 2, 2, 2, 4) +" "+ time2str(timenow(),1,1) +":"+ curuserid();
    print s;
    len = strlen(s);
    j = strScan (s,":",len,-len);
    for(k = len; k >= 1 ; k--)
    {
        if(j == k)
        {
            break;
        }
        s1 = substr(s,k,k);
        len--;
    }
    print s1;
    pause;
}

Sunday, May 8, 2011

Passing the parameters from the Form to Report..

http://dynamicsuser.net/forums/t/42147.aspx

In Button clicked method()
void clicked()
{
    Args        args = new args();
    ReportRun   reportRun;
    ;
    args.parm(emplTable.EmplId);
    args.name(reportstr(report2)); // report2 - ReportName
    reportRun = classFactory.reportRunClass(args);
    reportRun.init();
    reportrun.run();
    super();
}

In the report init method
public void init()
{
    ;
    try
    {
        if(element.args().parm())
        {
            this.query().dataSourceTable(tablenum(EmplTable)).addRange(fieldnum(EmplTable,EmplId)).value(element.args().parm());
            this.query().userUpdate(false);
            this.query().interactive(false);
            super();
        }
    }
    catch(exception::Error)
    {
        info("Error");
    }
}

Insertion of record at the end in the form while creating the new record...

In  Form -->datasource --> Properties --> StartPosition --> Last and
Override the Create method in the datasource as

public void create(boolean _append = false)
{
    _append = true;
    super(_append);
}

Wrting the data to csv file & open in the excel

static void AXtoCSVorExcel(Args _args)
{
    CommaIO     commaIO;
    str         fileName;
    LedgerTable ledgerTable;
    ;
   
    fileName    = WinAPI::getTempPath() + "LeagerAccounts" + ".csv";
    commaIO     = new CommaIO(fileName,"w");
   
    while select ledgerTable
    {
        commaIO.write(ledgerTable.AccountNum,ledgerTable.AccountName);
    }
   
    WinAPI::shellExecute(fileName);
}