Wednesday 15 April 2020

Pemikiran Komputasional

Pemikiran Komputasional ialah :


Teknik Leraian


Tekinik pengecaman Corak
Teknik  Peniskalaan
teknik Pengitlakan

Thursday 9 April 2020

Objects and Components

Starting up LiveCode

Starting up LiveCode
It seems obvious but the first step is to start up LiveCode. When you start LiveCode you will see the menu bar and toolbar at the top of the screen(1). The menu bar and toolbar give you access to all the things you would expect, new files, saving, script editors etc as well as useful resources including Rev Online and the dictionary. We'll go into all the options in more detail as we need them.
The Tools Palette (2) allows you to add controls to your application and switch between "edit" and "run" modes. Again we'll go into these in more detail later.

Stacks and cards

Stacks and cards
Applications in LiveCode are known as stacks and the separate screens which make these up are called cards. A stack can contain any number of cards and may also contain substacks. The substacks will generally provide specialist actions or implement specific parts of your application.

Your first stack

Your first stack
First things first, we need a stack so we can start building our application. Just go to the File menu (1) and select New Stack/Default Size (2). We now have a stack (3) containing a single card.

Run and Edit mode

Run and Edit mode
You can use the Tools Palette to switch between Run(1) and Edit(2) modes while you are working. When in Edit mode objects can be placed on the cards, resized and edited. When in Run mode no editing can take place but buttons etc can be clicked and results observed.

Adding controls to the stack

Adding controls to the stack
To add controls to the stack you simply drag the type of control you want over from the Tools Palette and place it on your card wherever you want it. Lets add a basic field and button to our card. Just select the field(1) on the Tools Palette and drag it to your card, then do the same with the button(2).

Object properties

Object properties
Now that we have a (very simple) interface set up what can we do with it? Every object in LiveCode has associated properties which specify how it looks and behaves. These can be altered when LiveCode is in Edit mode(1) and the easiest way to do this is using the Property Inspector (2). This can be opened by selecting the object(3) and clicking the inspector button on the menu bar(4). Alternatively you can open the Property Inspector by right clicking the object and selecting Property Inspector from the resulting menu or, alternatively, by double clicking the object itself.

The Property Inspector

The Property Inspector
The Property Inspector displays all of the object's properties, from its name and title to its display settings. You can use the property inspector to change the properties of an object. The best way to find out what a property does is to try changing it and see what happens. Hovering over an option in the Property Inspector will tell you the property name(1) which you can look up in the Dictionary if you want to find out more.
Here I have renamed the button to be called "Say Hello" (2).

Adding scripts to controls

Adding scripts to controls
If we want our application to do anything we need to start adding some LiveCode. Once an object has been created and assigned properties its behaviour can be specified by giving it a script.
Within LiveCode all scripts are written in the script editor(1) The easiest way to view this is to select the object you want to edit(2) and then click the code button on the menubar(3). Alternatively the object can be right-clicked and the Edit Script option can be chosen from the menu which appears.

Adding scripts to controls(2)

Adding scripts to controls(2)
Scripts in LiveCode send and handle messages which control action. Some messages, such as mouseUp, are sent automatically by the system while other, user messages, are sent by making what is equivalent to a method call. The messages an object sends and how it handles them specify how it reacts to events and generally behaves.
In this case we want something to happen when the button is clicked. The mouseUp message is sent automatically when the mouse button is clicked and released so we add the script for whatever action we want to take to the mouseUp handler. Here we want to say hello so our script is
on mouseUp
put "Hello World" into field 1
end mouseUp

Testing our script

Testing our script
To test our script and see what happens we need to switch to Run mode(1) and click on the button(2) ... and Hello World appears in the field.

Messages and the Message Path

Messages and the Message Path
When a message is sent to an object, it is often handled directly by a message handler in that object. However if no handler is present, the message will continue along a path until it finds a message handler that can respond to it. This makes it possible to group similar functionality together at different levels within your application. This behavior applies both to event messages sent as a result of a user action, and custom messages sent by script. It is therefore possible to write libraries of common functions.
The object hierarchy is closely related to the path that a message travels on. In most cases, when an object passes a message on, the message goes to the object's owner in the object hierarchy.
For a more detailed explanation of the Message Path see the lesson How to call a function or command in another object?

The Project Browser


The Application Browser

Hello World! 3 Ways

What's the first thing you want to learn to do with LiveCode? A "Hello World!" application of course.
This lesson will show you a variety of ways to say "Hello World!" using LiveCode.

Your first stack

Your first stack
First things first, we need a stack so we can start building our application. Go to the File menu and select New Stack - Default Size(1) We now have a stack containing a single card(2)

Edit mode

Edit mode
Selecting Edit Mode allows you to add controls to the stack, select controls and edit scripts and properties of controls.
In the Tools Palette select Edit Mode.

Adding a field to the stack

Adding a field to the stack
To add a field to the stack we can simply drag it onto our stack from the Tools Palette.

Browse mode

Browse mode
Selecting the Browse tool allows you to interact with the stack in non-editing mode. This tool is used for user actions such as clicking buttons and typing in fields.

Displaying Hello World! in the field

Displaying Hello World! in the field
We can then simply type "Hello World!" into the field.

Opening the Message Box

Opening the Message Box
When you start up LiveCode you should see the Message Box(1). If you cannot see it click the Message Box button in the Menubar(2).

Using the Message Box

Using the Message Box
The Message Box is a command line tool that allows you to try out short scripts and test parts of your program. It provides a convenient output window for debugging and can be used for editing and setting properties. It is one of the more useful components in LiveCode when you are starting out and wanting to try out simple scripts.
to output to the Message Box we simply type
put "Hello World!"
and press return to execute the command and there it is, "Hello World!" is displayed in the Message Box.
To put text into a field we can use almost the same script, we just also specify where to put the text
put "Hello World!" into field 1

Using a dialog box

Using a dialog box
Another option is to use a dialog box to display a message. For this all we need to do is use the answer command. Execute this line in the Message Box
answer "Hello World!"

Using a field and a button

Using a field and a button
If we don't want a field that can be edited manually we can use a label field and a button. Again we just drag them onto our stack from the Tools Palette.

Scripting the button

Scripting the button
Now we want to put "Hello World!" into the field when the button is clicked.
1. Go into Edit mode
2. Select the button and open the Script Editor for the button by clicking the Code button in the Menubar
We can reuse our line of LiveCode from earlier, this time we want it to be executed when the button is clicked. Enter this into the code editor:
on mouseUp
   put "Hello World!" into field 1
end mouseUp
Compile the script by clicking Apply(3), go into Run mode(4) and click the button.

Hello World


Opening LiveCode

Opening LiveCode


Creating a new mainstack
Creating a new mainstack
Select New Stack - Default Size from the File menu. Every project you create in LiveCode is a stack.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              

New stack

New stack
This is a new stack, it is a blank canvas ready for you to start creating your app.


Creating a button

Creating a button
Drag a button from the Tools Palette onto the stack.


Opening the Code Editor

Opening the Code Editor
Click the Code button in the MenuBar to open the Code Editor for the button


Adding code to the button

Adding code to the button


Adding code to the button (2)

Adding code to the button (2)
Add the code
answer "Hello World!"
to the button.


The answer command

The answer command displays a dialog box with a message to the user.

Applying the new code

Applying the new code
Click the Apply(1) button. The indicator(2) will turn green to show there are no errors.


Run mode

Run mode
Switch to Run mode to interact with the app.


Testing the button

Testing the button
Click the button.


The dialog box

The dialog box
After clicking the button you will see the message
    Hello World!
Click OK to dismiss the dialog.

Kriptografi Bahagian 3 - Transposition Cipher (Rail Fence, Columnar)

Kriptografi Bahagian 2 - Substitution Cipher (Atbash, Caesar, Pigpen)

Penyulitan dan Nyahsulit ,Reverse Dan Atbash Cipher, Ralat Buku Teks Dan ...