flat assembler
Message board for the users of flat assembler.
Index
> High Level Languages > Function in function |
Author |
|
baldr 23 Dec 2009, 13:43
lamar,
In C++ that is impossible. |
|||
23 Dec 2009, 13:43 |
|
Tyler 24 Dec 2009, 00:07
Code: int MainFunction(int hWnd,int SomeParam1,int SomeParam2) { return AdditionalFunction(hWnd);//Void functions cannot return stuff, since AdditionalFunction is an int make MainFunction an int. } int AdditionalFunction(int hWnd) { return hWnd+2;//In oreder to use hWnd you need to pass it as a param or declare it in AdditionalFunction. } But for any of them to be used you have to declare them like variables(kinda), you do that like this, Code: int MainFunction(int hWnd,int SomeParam1,int SomeParam2);//Notice the ; int AdditionalFunction(); Also, all the stuff I made comments on being wrong I fixed, look at your original code to find the difference. You should consider learning C first, it's more fun. |
|||
24 Dec 2009, 00:07 |
|
LocoDelAssembly 24 Dec 2009, 01:02
Tyler, I think he means the nested function/procedure capabilities Delphi/TurboPascal have.
Code: procedure foo(a: integer) function bar(): integer begin bar := 4 + a; { Notice it can access parameters and variables from its parent } end; begin WriteLn(bar()); end; { bar can't be called from here } The scope part perhaps could be solved by putting the foo and bar in a separate file and make bar static, but the other aspect may not be so easy/safe to emulate and you would have to manually pass the variables/arguments bar requires. |
|||
24 Dec 2009, 01:02 |
|
TmX 24 Dec 2009, 02:53
|
|||
24 Dec 2009, 02:53 |
|
LocoDelAssembly 24 Dec 2009, 03:12
Quote:
But thank you very much for mentioning it, I didn't know there was support for this. |
|||
24 Dec 2009, 03:12 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.