Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

Application Development with Harbour/Programming with Functions

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

A harbour function looks like this. FUNCTION calculateSum(a,b) LOCAL sum := a + b RETURN sum If you want to use above function calculateSum() you can simply do for example: sumTwoNumbers := calculateSum(2,4) //The value 6 is saved in sumTwoNumbers ? sumTwoNumbers //prints the value of sumTwoNumbers Step by step instructions to produce above result: Create a file called SumTwoNumbers.prg in directory C:\hb30\tests and open this file. Put the following code in this file: ******************SumTwoNumbers.prg PROCEDURE Main() Local sumTwoNumbers := calculateSum(2,4) ? sumTwoNumbers RETURN FUNCTION calculateSum(a,b) LOCAL sum := a + b RETURN sum ***************** C:\hb30\bin\hbmk2.exe SumTwoNumbers.prg SumTwoNumbers.exe //if right you see number "6" Notes The code of the function can be simplified (there is no need to declare a single local variable to store the result): FUNCTION calculateSum(a,b) RETURN a + b