Page 1 sur 1

WHILE block syntax

Publié : sam. févr. 09, 2019 3:29 pm
par compsystems
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;

Re: WHILE block syntax

Publié : dim. févr. 10, 2019 2:11 pm
par parisse
If you put a parenthesis after the while keyword, you select C-like syntax (while(){...}).

Re: WHILE block syntax

Publié : mar. févr. 26, 2019 2:44 pm
par compsystems
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

Re: WHILE block syntax

Publié : jeu. févr. 28, 2019 2:25 pm
par parisse
Indeed. I will fix that. In the meantime, just replace by end.