Forum > General
Nested procedures
Ten_Mile_Hike:
I realize that "Str" is a procedure not a function, but why does this work
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.B6Click(Sender:TObject);Type Seasons=(summer,fall,winter,spring);var names:Seasons; s:string;Begin for names in seasons Do Begin str(names,s); M1.lines.Add(s); end;end;
but this is an error
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.B6Click(Sender:TObject);Type Seasons=(summer,fall,winter,spring);var names:Seasons; s:string;Begin For names in seasons Do M1.lines.Add(str(names,s) );end;
Fibonacci:
A procedure doesnt return anything, you cannot use it as a parameter when calling M1.lines.Add()
Ten_Mile_Hike:
Hello Fibonacci,
Yes; that is why I noted "I know that it is a procedure not a function"
My question is what is it about the pascal specification that forbids
the statement from being "evaluated" even if it doesn't "return" a
value?
Fibonacci:
Maybe it can be evaluated, but anyway Add() requires a parameter of a specified type, and as you know a procedure doesnt return anything
BTW. Just now I found another Internal Error :)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure proc;beginend; procedure test(const o);beginend; begin test(proc); // project1.lpr(10,3) Error: Internal error 2011010304end.
egsuh:
Pascal compiler is known to be strict in data type. So, M1.Lines.Add will require a string-type constant as a parameter, nothing else (unless it is overloaded with other types).
You may define your own function.
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function SeasonStr(season: Seasons): string; begin Str(season, result);end; and then
for names in Seasons do M1.Lines.Add(SeasonStr(names));
should work (I hope).
Navigation
[0] Message Index
[#] Next page