Example 9: First PyS60 program
import appuifwword = appuifw.query(u"Type your name", "text")
appuifw.note(u"Greetings from " + str(word))
We could define a function and put the two lines of code inside
the function. This is what we do in Example 10, where the name of
the function is askword(). Within a function, the execution proceeds
sequentially as usual. Functions are just a way to divide and structure
code into small chunks that are given a name.
Example 10: First function
import appuifw
def askword():
word = appuifw.query(u"Type a word", "text")
appuifw.note(u"The word was: " + str(word))
Any time we want to carry out this task, that is, to execute these two
lines of code, we just call the function askword():
askword()
askword()
In this case, it asks for a word twice.
You have been calling functions all the time in the previous chapters.
For example:
messaging.sms_send("+358...", u"Greetings from PyS60")
appuifw.note(u"I love MobileArt")
These lines from earlier examples, call the function sms send in the
messaging module and the function note in the appuifw module.
No comments:
Post a Comment