Thread overview
D Program code on CLS
Nov 14, 2013
Vincent
Nov 14, 2013
Jesse Phillips
Nov 14, 2013
Vincent
Nov 14, 2013
Ali Çehreli
Nov 14, 2013
seany
Nov 15, 2013
Jesse Phillips
Nov 14, 2013
nazriel
November 14, 2013
how can I clear the screen for example I input first letter (A)
and second letter (B) and show the result AB then after pressing
enter it will clear the screen before it display again the Input
first letter


Input first letter : A
Input second letter: B
result: AB
Input first letter: _

it should not be displaying the previous output like this...
After showing the result it should be cleared the previous output
before it shows the input first letter again...
November 14, 2013
On Thursday, 14 November 2013 at 03:35:59 UTC, Vincent wrote:
> how can I clear the screen for example I input first letter (A)
> and second letter (B) and show the result AB then after pressing
> enter it will clear the screen before it display again the Input
> first letter
>
>
> Input first letter : A
> Input second letter: B
> result: AB
> Input first letter: _
>
> it should not be displaying the previous output like this...
> After showing the result it should be cleared the previous output
> before it shows the input first letter again...

I've been using std.process.system("cls"); which I guess is std.process.execute("cls"); now.

If you want something cross platform you're probably getting into ncurses like libraries.
November 14, 2013
import std.stdio,std.cstream;

void main(string[] args)
{
	while (true)
	{
		writeln ("Calculator Menu");
		writeln();
		writeln();
		writeln (" 1 - Add");
		writeln (" 2 - Subtract");
		writeln (" 3 - Multiply");
		writeln (" 4 - Divide");
		writeln (" 5 - EXIT");
		writeln();
		write ("Selected Number: ");
						
		int operation;
		readf (" %s", &operation);
		
		if ((operation < 1) || (operation > 5))
		{
			writeln ("Invalid Operation");
			readln();
			readln();
			continue;
		}
		if (operation == 5)
		{
			writeln ("Goodbye!!!");
			readln();
			readln();
			break;
		}
		
		int first;
		int second;
				
		write ("First Number:    ");
		readf (" %s", &first);
		
		write ("Second Number:   ");
		readf (" %s", &second);
		
		int result;
		
		if (operation == 1)
		{
			result = first + second;
		}
		else if (operation == 2)
		{
			result = first - second;
		}
		else if (operation == 3)
		{
			result = first * second;
		}
		else if (operation == 4)
		{
			result = first / second;
		}
			else
		{
			writeln ("There is an error!");
			writeln ("This condition should never occurred.");
			break;
		}
		writeln ("Result     : ", result);
		readln();
		din.getc();
	}
}

--------------------------
This is the code. where or what code will I use for clear the screen?
November 14, 2013
On Thursday, 14 November 2013 at 03:35:59 UTC, Vincent wrote:
> how can I clear the screen for example I input first letter (A)
> and second letter (B) and show the result AB then after pressing
> enter it will clear the screen before it display again the Input
> first letter
>
>
> Input first letter : A
> Input second letter: B
> result: AB
> Input first letter: _
>
> it should not be displaying the previous output like this...
> After showing the result it should be cleared the previous output
> before it shows the input first letter again...

You mean something like that:

---

import std.stdio;
import core.thread;

void main() {
    foreach (i; 0..10) {
        write("\r", i);
        stdout.flush();
        Thread.sleep(250.msecs);

    }

}

---

If yes, you want to play with carriage return and flushing terminal.
November 14, 2013
On 11/13/2013 08:59 PM, Vincent wrote:

> This is the code. where or what code will I use for clear the screen?

My Linux console environment has 'clear'. That's why I used system("clear") below. You may need to use system("cls") if you are e.g. on Windows.

import std.stdio;
import std.process;
import core.thread;

void main(string[] args)
{
    while (true)
    {
        writeln ("Calculator Menu");
        write ("Selected Number: ");

        int operation;
        readf (" %s", &operation);

        enum duration = 3.seconds;

        writefln("Thank you for %s! See you in %s.", operation, duration);
        Thread.sleep(duration);

        system("clear");
    }
}

Ali

November 14, 2013
what is the tango equivalent for system?

In my case, since my dmd, tango and things are in custom folders, i notice that i am getting problems when importing both std.stdio and tango.io.stdout


On Thursday, 14 November 2013 at 19:00:00 UTC, Ali Çehreli wrote:
> On 11/13/2013 08:59 PM, Vincent wrote:
>
>> This is the code. where or what code will I use for clear the screen?
>
> My Linux console environment has 'clear'. That's why I used system("clear") below. You may need to use system("cls") if you are e.g. on Windows.
>
> import std.stdio;
> import std.process;
> import core.thread;
>
> void main(string[] args)
> {
>     while (true)
>     {
>         writeln ("Calculator Menu");
>         write ("Selected Number: ");
>
>         int operation;
>         readf (" %s", &operation);
>
>         enum duration = 3.seconds;
>
>         writefln("Thank you for %s! See you in %s.", operation, duration);
>         Thread.sleep(duration);
>
>         system("clear");
>     }
> }
>
> Ali

November 15, 2013
On Thursday, 14 November 2013 at 21:42:34 UTC, seany wrote:
> what is the tango equivalent for system?
>
> In my case, since my dmd, tango and things are in custom folders, i notice that i am getting problems when importing both std.stdio and tango.io.stdout

For tango it looks like you want tango.sys.Process

http://www.dsource.org/projects/tango/docs/stable/tango.sys.Process.html