Jump to content
View in the app

A better way to browse. Learn more.

3D-Modellbahn Studio

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

@ademes

Hello ademes,

return gives the result

try this:

 function foo(n)
   print ("function foo")
   return n*2
end
n = foo(4)

print("N = ",n)
N =     8

Regards Martin

Ok!  Thank you martin51.  This solves also my previous post.

Regards

André

Have you tried your code in Lua-Demo?
Doesn't work there either.

Reason: You don't catch the value that the function returns.
And n is a local variable in foo. If you try to print n outside foo, it contains nil.

try this instead:

function foo(n)
  print ("function foo")
  return n*2
end
catch = foo(4)  
print ("N = ", catch) 

 

postscript: I see that Martin gave you the same advice. ;)

Edited by Goetz

For further clarification, here's a more generic explanation:

whatever a function returns is placed at the very position where the function call happened. Meaning that you use the function call in place of the value. The function is called and fills the place by returning a value (or more).

function buildSquare(arg)
  return arg * arg
end

number = 3
print( "The square of ", number, " is ", buildSquare(number) )

 

Hi

Kann das sein, das da nix kommt? Weder wenn man in der EV ist noch wenn man im MBS ist (da kommt immerhin pause)

lua.JPG.a151407ae41a57c1d3b326f64e540235.JPG

Cheers

Tom

Uupps.....man muss das EV fenster vorher malanklicken, so  als wuerde man schon etwas darin schreiben wollen.;)

Cheers

Tom

@metallix Hi Tom,

und wenn du vorher einen Ausdruck markierst, bekommst du sogar Hilfe zu genau diesem Ausdruck. ;) Ist schon genial, das Ding.

Gute Nacht ... äh ... nee, für dich nicht, oder?

Hi Timba

Seit ihr die uhren verdreht habt sind es wieder genau 12 Std zeitunterschied. :) Also schreibe ich dir gerade "zurueck aus der zukunft", weil hier ist Mo 28.10.19 12h00 mittag (und feiertag > Labourday)9_9

Cheers

Tom

Hi Tom,

Feiertag = Labourday? Dann ist Labour wohl das englisches Wort für Labern. :D Oder was macht ihr an einem Feiertag?

Schelmischen Gruß
Timba

vor 4 Stunden schrieb Timba:

Hi Tom,

Feiertag = Labourday? Dann ist Labour wohl das englisches Wort für Labern. :D Oder was macht ihr an einem Feiertag?

Schelmischen Gruß
Timba

Hi Timba

In gewisser Weise schon. Die werktätigen bleiben halt der Arbeit fern und labern zu hause oda sonst wo. Gemeinsames rituelles betrinken, wobei der Nachschub mittels leiterwagen oder gleich traktorgespann mitgefuehrt wird, kennt man hier in der Form nicht. Manche werden wohl auch eine private betrinkung ausrichten, Abba da Allohol hier vergleichsweise teuer ist, und jeder das mitbringen muss was er zu trinken gedenkt, sind diese Partys eher kurz. Da wird immer hurtig gekübelt, auch damit in der später nachlassenden Aufmerksamkeit kein raubtrinker die eigenen Vorräte plündert, und somit enden Partys ungefähr dann wenn sie in Germanien erst richtig los gehen würden. Banausen halt.

Cheers

Tom

 

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.