Make my program interactive and incease the number of digit.

9 views
Skip to first unread message

schtroumpfreestyle

unread,
Jul 2, 2009, 3:25:21 AM7/2/09
to Sysquake
Hello again,

I would like to know if it is possible in sysquake LE to have some
interactivity.
Indeed I have a code in C asking the user to enter some numbers and
then these numbers are stored in vectors:
I saw in the manual that you can display dialogs box but it is not
explained how to store and wait for value like in the extract C progr
below:

double lastDate=0;
for(int i=0 ; i < r ; i++)
{
double buffer=0;
do{
cout << "Please enter the time of the " << i+1 << "-th failure
\n";
cin >> buffer;
if (buffer < lastDate){ cout << "Error, the time of this
failure must be greater or equal than " <<
lastDate << endl; };
}while(buffer < lastDate);
t.push_back(buffer);
lastDate = buffer;
}

Is it possible to display more than 4 digits? for example 1/3=
0.33333333 ?
sorry if my question seems too easy

thank you in advance for your help
Regards
SP

Yves Piguet

unread,
Jul 3, 2009, 11:11:27 AM7/3/09
to sysq...@googlegroups.com
On 2 juil. 09, at 09:25, schtroumpfreestyle wrote:

> I would like to know if it is possible in sysquake LE to have some
> interactivity.

In Sysquake, "interactivity" usually means direct manipulation of
graphics with the mouse, with draw and mousedrag handlers.

> Indeed I have a code in C asking the user to enter some numbers and
> then these numbers are stored in vectors:
> I saw in the manual that you can display dialogs box but it is not
> explained how to store and wait for value like in the extract C progr
> below:

> [...]


> cout << "Please enter the time of the " << i+1 << "-th failure
> \n";
> cin >> buffer;

Standard input is 0, standard output 1. You can use fscanf and fprintf:

fprintf(1, 'Enter some number: ');
x = fscanf(0,'%g')

or simply

fprintf('Enter some number: ');
x = fscanf('%g')

since they're the default values. Note that files (opened with fopen)
aren't supported in Sysquake LE.

> Is it possible to display more than 4 digits? for example 1/3=
> 0.33333333 ?

For the default output format used to display expression not followed
by a semicolon, use "format":

format long
pi
3.141592653589793

For more control, use fprintf:

fprintf('1/3=%.8f\n', 1/3);

1/3=0.33333333

Hth,

Yves

Reply all
Reply to author
Forward
0 new messages