Главная » Просмотр файлов » John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG

John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (779881), страница 8

Файл №779881 John.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG (Symbian Books) 8 страницаJohn.Wiley.and.Sons.Rapid.Mobile.Enterprise.Development.for.Symbian.OS.An.Introduction.to.OPL.Application.Design.and.Programming.May.2005.eBook-LinG2018-01-10СтудИзба
Просмтор этого файла доступен только зарегистрированным пользователям. Но у нас супер быстрая регистрация: достаточно только электронной почты!

Текст из файла (страница 8)

ThisIsMoreThanOneWord$)• commands are fully capitalized (with three exceptions – Graphicscommands are prefixed with a lowercase ‘g’, Menu commands witha lowercase ‘m’, and Dialog commands with a lowercase ‘d’ – forexample, gPRINT, mCARD,or dTEXT).Elements of Hello WorldLet’s have a look at what makes up our program, line by line.PROC Main:The command PROC, short for procedure, gives the next small lump ofcode its own unique name, in this case "Main". The colon ":" after the28INTRODUCING THE TOOLS OF OPLname is always required to signify where the name ends and the codebegins.PRINT "Hello World"When an OPL program is first launched, you have a blank screen.

In fact,OPL creates a default window that takes up the whole screen – to youit appears that you have a white screen to work with. This is called awindow, and we’ll look at using windows in Chapter 5. For the moment,we’ll just use the PRINT command. This takes a string and displays it onthe screen.You should know from the previous chapter that a string is a collectionof letters and numbers inside quotation marks.

So our PRINT commanddisplays Hello World on our empty window, not "Hello World" – ifyou wanted to display "Hello World" with the quotation marks, yourPRINT command would read PRINT """Hello World""", with threequotation marks on either side. When your program is run, OPL will know,on seeing three quotation marks, that it should display one on the screen.GETThis will get the next keypress event from your phone. An event issomething that passes information to the program. This could be a keypress, a pen tapping on the screen, a message from the processor, ora variety of other things. Events are how users communicate with yourprogram. In the next chapter, we’ll see how events can be read, stored,and used by the program.GET waits for an keypress event to happen. This event is not neededby the Hello World, so we don’t read it or use it in any way.

But it doesmean the text stays on the screen until we press a key.ENDPSignifies the end of our procedure. As it is the first procedure in theprogram, the program will now stop. If it was the second or subsequentprocedure, the program would jump back to the line after that whichcalled this procedure.2.4.3 TranslationOnce you’ve typed in your OPL source code, you need to translate thesource code into object code so the OPL Runtime (on the phone) canunderstand it. You can do this from inside Program if you are coding onyour Symbian OS phone, or through the command line if you are codingon your PC.HOW WE PROGRAM29Translation from Program (on the Smartphone)The ‘Translate’ option can be found under the ‘Build’ menu.

When youpress this, your code will be compiled, and the resulting .opo file will besaved in the same directory as the source code.You will also be given the option to immediately run the .opo codeafter translation without having to run a file manager.Translation from PC Command LineAs mentioned previously, OPLTran is a command line tool you canuse to compile OPL source code on your PC. Open up your commandprompt, and navigate to the directory with the Hello World source code.If you are using the directory structure we’ve suggested, you should findit at C:\OPL\HelloWorld\Source\HelloWorld.tpl. Type in thecommand line:OPLTRAN HelloWorld.tplThis will compile the code into a file called HelloWorld.opo. This fileshould be copied from your PC to your Symbian OS phone.2.4.4 Transfer to PhoneThis is only needed if you translated your OPL program on a PC.

You needto get the .opo file from your PC onto your phone to test it. If you haveBluetooth or an infrared port on your PC you can transfer the file directlyto your phone where it should appear in the Inbox and you can try to runit directly from there. Alternatively, you can use a PC-based file managertool, as mentioned above to copy the .opo file to a location of your choiceon your phone and then use a phone-based file manager to run it.You might want to look at an application called "Forward" (www.compsoc.man.ac.uk/∼ashley) which allows you to copy a file from theInbox of a Series 60 device into a specified directory on the C:\ drive ofyour Series 60 device.If this all sounds rather convoluted, bear in mind it’s only you (thedeveloper) who needs to do this.

For any applications you seek to deliverto end-users, you build a SIS file and avoid these problems – more inChapter 8.2.4.5Running Inside the EmulatorIf you are working on a PC, then it is possible to run .opo files insidethe Emulator that comes with the SDK. You should locate the ‘rootdirectory’ of the file system for the emulator. If you are using the UIQ30INTRODUCING THE TOOLS OF OPLSDK and have installed it to the default path, then you can find it here:C:\Symbian\UIQ_21\epoc32\wins\c\Other SDKs will require you to change the UIQ 21 directory to somethingmore appropriate.Copy your .opo file to a directory under here.

I suggest you createan OPL directory and mirror the directory structure suggested above.Run the file manager inside the Emulator, go to this directory, and runthe .opo.2.4.6 Problems?Did the program do exactly what you wanted it to? In a simple programlike Hello World, probably. But as your programs gain complexity, you’llfind that small errors – so-called ‘bugs’ – may arise.Any computer is incredibly strict in how you must use it. SubstitutingName$ for Name% in your source code may not stop the programtranslating in all circumstances, but it will stop it running correctly.One advantage of translating on the phone with Program is that it willshow you directly the line where the error occurred. So look carefully atwhat you see, double checking the syntax of commands.

OPLTran willalso give you a text output of the line number in question.Other errors can be from not declaring variables correctly – in whichcase you might need to look a few lines back in your code to check whatyou typed when you set something up.

OPL has a set of commands calledDECLARE EXTERNAL and EXTERNAL, which help at translate time byensuring you’re using correct variables and procedure names, etc. It isrecommended practice to use these commands, but for the programswe’re writing in this introductory book we are dispensing with it forbrevity. If you’re interested in more details, see the command referencein the Appendix.The hardest errors to find are when the code is typed in correctly,but you have made a logical error.

Remember that your program will doexactly what you ask it to do, so you should work through your codeline by line, following in your head what you are asking your programto do.Bug hunting is part and parcel of programming, and any programmerwho says otherwise is lying. Being able to think clearly at all stages ofprogramming will cut down bugs.2.5 SummaryThis chapter introduced you to both the tools and the elements of OPL.Like any computer language, there are different parts to OPL and weSUMMARY31looked at all of these, and noted the different file extensions used:• source code (.tpl as a text file on a PC, or .opl on the Symbian OSpowered device)• header files to make reading code easier (.tph or .oph)• compiled code (.opo)• compiled code as an application (.app)• graphics file (.mbm)• installation file (.sis).We then looked at one way of developing with all these tools, andshowed you the code/test/debug path that you will continue to use as youdevelop OPL programs.Finally, we looked at how to run your program on the SDK emulatoror on your Symbian OS phone.3Event CoreIn this chapter you will learn:• how we take ideas and turn them into OPL code• about the Event Core: a skeleton program we use as a basis of anynew OPL program• using Event Core on different Symbian OS platforms• how to store information when you close a program• how to read in messages from the processor• how to read and act on pen taps• how to read and act on key presses.3.1 Event Core? What is it Good for?3.1.1 What is Event Core?So now that we know the basic building blocks of a program and howto use all our programming tools, it’s time to start doing some real-worldprogramming.In the real world, we need to think about how our OPL program willinteract with the user, the rest of the operating system, and the processor.To study this, we will build up a skeleton program that does all the thingsa good program should do.

It won’t actually ‘do’ anything useful for auser, but it will provide a starting point for every other program in thisbook, and can be used by you for all your own programs too.This core will react to events sent to it from various I/O devices, henceits name, Event Core. Think of it as the foundations of your program, thestructure you can build everything else around.343.1.2EVENT COREWhat Should it Do?Think of the other programs on your phone and what they do. By that Idon’t mean their high-level function (i.e.

Характеристики

Тип файла
PDF-файл
Размер
3,18 Mb
Материал
Тип материала
Высшее учебное заведение

Список файлов книги

Свежие статьи
Популярно сейчас
А знаете ли Вы, что из года в год задания практически не меняются? Математика, преподаваемая в учебных заведениях, никак не менялась минимум 30 лет. Найдите нужный учебный материал на СтудИзбе!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
6384
Авторов
на СтудИзбе
308
Средний доход
с одного платного файла
Обучение Подробнее