[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-usability
Subject:    Re: idea calculator - bc and national language?
From:       Lubos Lunak <l.lunak () suse ! cz>
Date:       2004-07-24 9:27:37
Message-ID: 200407241127.38631.l.lunak () suse ! cz
[Download RAW message or body]

Dne čt 22. července 2004 15:18 Sébastien Laoût [temporar] napsal(a):
> Le mer 21/07/2004   09:42, Lubos Lunak a écrit :
> > > What about replace all ',' by '.' before passing them to perl ?
> > > Seem trivial and it would works.
> >
> >  The code is in kdebase/kdesktop/minicli.cpp near the bottom, feel free
> > to play with it. I'm not sure it'd be really that trivial.
>
> QString Minicli::calculate(const QString &exp)
> {
>    QString result;
>    QString cmd;
> //<<
>    if( !KStandardDirs::findExe( "bc" ).isEmpty()) {
>       QString expWithPoints = exp.replace(",", ".");
>       cmd = QString("echo \"scale=20;%1\" | bc" ).arg(expWithPoints);
>    } else
> //>>
>       cmd = QString("echo $((%1))").arg(exp);
>    FILE *fs = popen(QFile::encodeName(cmd).data(), "r");
>    if (fs)
>    {
>       QTextStream ts(fs, IO_ReadOnly);
>       result = ts.read().stripWhiteSpace();
>       pclose(fs);
>    }
>    return result;
> }
>
> No ?
> A problem with that ?
> I search... but I find it trivial.
> But I'm not an expert hacker :-)

 Nothing is trivial :). There's no conversion the other way around. It also 
doesn't check if "," really is the separator.

-- 
 Lubos Lunak
 KDE Developer
_______________________________________________
kde-usability mailing list
kde-usability@kde.org
https://mail.kde.org/mailman/listinfo/kde-usability

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic