WHILE block syntax

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

WHILE block syntax

Message par compsystems » sam. févr. 09, 2019 3:29 pm

Hello, the WHILE block syntax is as follows.

Code : Tout sélectionner

function while_example_()
begin 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5) 
        do
		printf( string(n) );
		n := n + 1; 
	end
	
	return Done;
end;


function while_example_1()
begin 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5) 
	begin 
		printf( string(n) );
		n := n + 1; 
	end
	
	return Done;
end;


function while_example_2()
{ 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5) 
	{ 
		printf( string(n) );
		n := n + 1; 
	}
	
	return Done;
};

function while_example_3()
begin 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5) 
	begin 
		printf( string(n) );
		n := n + 1; 
	end_while
	
	return Done;
end;
  
But these two combinations do not work

Code : Tout sélectionner

function while_example_4()
begin 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5)
        do
  
		printf( string(n) );
		n := n + 1; 
	end_while
	
	return Done;
end;


function while_example_5()
begin 
	local n;
	assume( n, integer );

	DispG; ClrIO; ClrGraph;
	n:=1; 
	while (n <= 5)
 
		printf( string(n) );
		n := n + 1; 
	end_while
	
	return Done;
end;

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: WHILE block syntax

Message par parisse » dim. févr. 10, 2019 2:11 pm

If you put a parenthesis after the while keyword, you select C-like syntax (while(){...}).

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: WHILE block syntax

Message par compsystems » mar. févr. 26, 2019 2:44 pm

suppressing parentheses, does not recognize end_while

Code : Tout sélectionner

function while_example( )
begin
	local n;
	assume( n, integer );

	DispG; ClrIO; 

	n := 1;
	while  n <= 5  do
		printf( n );
		n := n + 1;
	end_while

	return "Done";
end

parisse
Messages : 5739
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: WHILE block syntax

Message par parisse » jeu. févr. 28, 2019 2:25 pm

Indeed. I will fix that. In the meantime, just replace by end.

Répondre