SlideShare a Scribd company logo
1 of 10
Download to read offline
Ring Documentation, Release 1.5.2
58.1 The Designer Windows
• Toolbox : To select controls to be added to the window.
• Properties : To set the properties of the active window or controls.
• Design Region : To select, move and resize the window and the controls.
58.2 The Toolbox
We have many buttons.
• Lock : We can use it to draw many controls of the same type quickly.
• Select : We can use it to select a control in the Design Region
• Controls Buttons : Select a control to be added to the window.
58.3 The Properties
• When we select the window or one control, We will have the selected object properties.
• Also In the properties window we have a combobox to select the active control.
• Some properties provide a button next to the property value. We can click on the button to get more options.
• When we select more than one control, We will have options for multi-selection
58.1. The Designer Windows 655
Ring Documentation, Release 1.5.2
58.4 Running Forms
When we save the form file (*.rform), The Form Designer will create two Ring files
• The Controller Class
• The View Class
For example, if the form file is helloworld.rform
The form designer will generate two files
• helloworldcontroller.ring
• helloworldview.ring
To run the program, Open the controller class file then click the Run button (CTRL+F5)
Tip: When you open a form using Ring Notepad, the controller class will be opened automatically, So we can press
(CTRL+F5) or click on the Run button while the form designer window is active.
58.5 Events Code
1. Just type the method name in the event property.
58.4. Running Forms 656
Ring Documentation, Release 1.5.2
(2) Then write the method code in the controller class.
58.5. Events Code 657
Ring Documentation, Release 1.5.2
In this example we write
func CloseWindow
oView.win.close()
Where inside the controller class, We uses the oView object to access the form.
Another Example :
58.5. Events Code 658
Ring Documentation, Release 1.5.2
The Event Code
func SayHello
oView {
LineEdit2.setText("Hello "+ LineEdit1.text() )
}
58.6 Keyboard Shortcuts
After selecting one or group of controls
• Use the Arrows (Up, Down, Left and Right) to move them around.
• Shift + the Arrows (Up, Down, Left and Right) to Resize the controls.
• Del button to delete the controls.
• CTRL+SHIFT+V to Duplicate the controls.
58.7 Menubar Designer
From the Window properties we can open the Menubar Designer
58.6. Keyboard Shortcuts 659
Ring Documentation, Release 1.5.2
58.8 Window Flags
From the Window properties we can open the Window Flags window.
58.8. Window Flags 660
Ring Documentation, Release 1.5.2
58.9 Entering Items
For some controls like the List Widget we can enter items separated by comma ‘,’
58.10 Using Layouts
1. To use layouts, At first add the layout control to the window.
2. Use the window “Set Layout” property to determine the main layout.
3. From the layout properties determine the controls and the layout type.
58.11 More Samples and Tests
Check the folder : ring/applications/formdesigner/tests
Online : https://github.com/ring-lang/ring/tree/master/applications/formdesigner/tests
58.9. Entering Items 661
CHAPTER
FIFTYNINE
SCOPE RULES FOR VARIABLES AND ATTRIBUTES
In this chapter we will learn about scope rules and how Ring find variables.
Also we will learn about conflicts and how to solve/avoid them.
The next information are important once you start developing large applications using Ring
These application may uses
• Global variables (Try to avoid them)
• Classes (Object-Oriented)
• braces { } to access objects
• Declarative Programming
• Natural Programming
59.1 Three Scopes
In Ring we have three scopes :-
1. Public/Global Scope - Each variable you define in the statements part (before functions and classes)
2. Object Scope - When you are inside an object (Inside class method or using { } to access the object )
3. Local Scope - Related to functions and methods
59.2 Defining Variables and Variables Access
1. Ring uses lexical scoping, i.e. the scope of the variable is based on where we defined the variable.
2. Inside braces { } when you access an object, You will change the current active object scope to this object scope
but you still can access the global scope and the local scope.
3. After the ‘Class’ keyword and the class name, when you write variable names to be defined as attributes, You
still can access the global scope.
In this region (class region - after the class name and before methods) we have
• Global Scope —-> The Global Scope
• Object Scope —-> The Object Scope
• Local Scope —-> The Object Scope
662
Ring Documentation, Release 1.5.2
Note: Since the local scope in the class region point also to the object scope in this region, we can use nested braces
and still have access to the object scope of the class through the local scope.
Tip: You can create windows and controls as attibutes by defining them in this region.
Tip: In the class region if you created objects and used braces {} to access them then using self.attribute inside braces
will use the class (not the object that you access) because you have access to the class through the local scope.
4. Function Parameters are automatically defined in the local scope.
59.3 How Ring find the variable?
1 - Search First in the Local Scope
if not found !
2 - Search in the Object Scope
if not found !
3 - Search in the public scope
if not found —-> Runtime Error
if found —-> Check if we can do optimization to avoid searching next time (Cache / Pointers for performance).
59.4 Using Object.Attribute
When we use object.attribute the search will be in the object attributes only.
I.e. no search will be done in the local scope or in the global scope for the object attribute.
Note: Using self.attribute will search for the first self before searching for attributes.
59.5 The Self Object
The self object is a reference to the current object that we can use from the class methods.
When we are inside class method and use Self we mean the object that will be created from this class.
Inside the class methods if we used Braces { } this will change the current object scope and self will be changed also
inside braces to reference the object that we access using Braces.
Inside the Class Region (after the class name and before any method) we have access to the object through the object
scope and the local scope also. In this region using Self will always be a reference to the class object. if we used
Braces to change the object scope then used Self inside Braces, Also self will be a reference to the class object (not
the object that we already access using braces) because in the class region we have :-
• Global Scope —> Global Scope
• Object Scope —> Object Scope
59.3. How Ring find the variable? 663
Ring Documentation, Release 1.5.2
• Local Scope —> Object Scope
And using Braces changes the object scope only (not the local scope) and when Ring search for variables it will search
in the Local Scope first so it will find self in the class that we are inside.
59.6 How Ring Define Variables and Attributes
Ring will use the variable name in the Assignment operation
1 - Search using the variable name
2 - If not found —> Avoid the runtime error and define the variable in the current scope
3 - If found —> Use the variable and don’t define anything in the current scope
• In the global region (before any function or class) the current scope is the global scope.
• In the class region (after the class name and before any method) the current scope is the object attributes.
• In Functions and methods the current scope is the local scope.
59.7 Conflict between Global Variables and Class Attributes
Look at this example:
name = "test"
o1 = new person
see o1
class person
name
address
phone
In the previous example we have a global variable called ‘name’ inside the class person.
when we use the variable ‘name’, Ring will start the search operation and will try to find it.
if found —> Use it
if not found —> Define new attribute
But the variable name is a global variable, so it will be found and used!
We will not have the attribute name! added to the object.
Solution (1) - Use the Main Function
func main
name = "test"
o1 = new person
see o1
class person
name
address
phone
Solution (2) - Use special mark for global variable names like $
59.6. How Ring Define Variables and Attributes 664

More Related Content

What's hot

The Ring programming language version 1.6 book - Part 75 of 189
The Ring programming language version 1.6 book - Part 75 of 189The Ring programming language version 1.6 book - Part 75 of 189
The Ring programming language version 1.6 book - Part 75 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 52 of 84
The Ring programming language version 1.2 book - Part 52 of 84The Ring programming language version 1.2 book - Part 52 of 84
The Ring programming language version 1.2 book - Part 52 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 74 of 189
The Ring programming language version 1.6 book - Part 74 of 189The Ring programming language version 1.6 book - Part 74 of 189
The Ring programming language version 1.6 book - Part 74 of 189Mahmoud Samir Fayed
 
Unit testing in xcode 8 with swift
Unit testing in xcode 8 with swiftUnit testing in xcode 8 with swift
Unit testing in xcode 8 with swiftallanh0526
 
Wj 1101-se6-lab2
Wj 1101-se6-lab2Wj 1101-se6-lab2
Wj 1101-se6-lab2bala369
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threadsDevaKumari Vijay
 
Interface result set
Interface result setInterface result set
Interface result setmyrajendra
 
Chapter 5:Understanding Variable Scope and Class Construction
Chapter 5:Understanding Variable Scope and Class ConstructionChapter 5:Understanding Variable Scope and Class Construction
Chapter 5:Understanding Variable Scope and Class ConstructionIt Academy
 
Effective Unit Test Style Guide
Effective Unit Test Style GuideEffective Unit Test Style Guide
Effective Unit Test Style GuideJacky Lai
 

What's hot (20)

The Ring programming language version 1.6 book - Part 75 of 189
The Ring programming language version 1.6 book - Part 75 of 189The Ring programming language version 1.6 book - Part 75 of 189
The Ring programming language version 1.6 book - Part 75 of 189
 
The Ring programming language version 1.2 book - Part 52 of 84
The Ring programming language version 1.2 book - Part 52 of 84The Ring programming language version 1.2 book - Part 52 of 84
The Ring programming language version 1.2 book - Part 52 of 84
 
The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185The Ring programming language version 1.5.4 book - Part 74 of 185
The Ring programming language version 1.5.4 book - Part 74 of 185
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Oops
OopsOops
Oops
 
The Ring programming language version 1.6 book - Part 74 of 189
The Ring programming language version 1.6 book - Part 74 of 189The Ring programming language version 1.6 book - Part 74 of 189
The Ring programming language version 1.6 book - Part 74 of 189
 
Unit testing in xcode 8 with swift
Unit testing in xcode 8 with swiftUnit testing in xcode 8 with swift
Unit testing in xcode 8 with swift
 
Hemajava
HemajavaHemajava
Hemajava
 
Wj 1101-se6-lab2
Wj 1101-se6-lab2Wj 1101-se6-lab2
Wj 1101-se6-lab2
 
Code smells
Code smellsCode smells
Code smells
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Java static keyword
Java static keywordJava static keyword
Java static keyword
 
Unit 4 exceptions and threads
Unit 4 exceptions and threadsUnit 4 exceptions and threads
Unit 4 exceptions and threads
 
Interface result set
Interface result setInterface result set
Interface result set
 
Chapter 5:Understanding Variable Scope and Class Construction
Chapter 5:Understanding Variable Scope and Class ConstructionChapter 5:Understanding Variable Scope and Class Construction
Chapter 5:Understanding Variable Scope and Class Construction
 
Junit basics
Junit basicsJunit basics
Junit basics
 
testng
testngtestng
testng
 
Effective Unit Test Style Guide
Effective Unit Test Style GuideEffective Unit Test Style Guide
Effective Unit Test Style Guide
 
Java
JavaJava
Java
 
22 multi threading iv
22 multi threading iv22 multi threading iv
22 multi threading iv
 

Similar to The Ring programming language version 1.5.2 book - Part 69 of 181

The Ring programming language version 1.8 book - Part 79 of 202
The Ring programming language version 1.8 book - Part 79 of 202The Ring programming language version 1.8 book - Part 79 of 202
The Ring programming language version 1.8 book - Part 79 of 202Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 83 of 210
The Ring programming language version 1.9 book - Part 83 of 210The Ring programming language version 1.9 book - Part 83 of 210
The Ring programming language version 1.9 book - Part 83 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.4 book - Part 20 of 30
The Ring programming language version 1.4 book - Part 20 of 30The Ring programming language version 1.4 book - Part 20 of 30
The Ring programming language version 1.4 book - Part 20 of 30Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 56 of 88
The Ring programming language version 1.3 book - Part 56 of 88The Ring programming language version 1.3 book - Part 56 of 88
The Ring programming language version 1.3 book - Part 56 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 69 of 180
The Ring programming language version 1.5.1 book - Part 69 of 180The Ring programming language version 1.5.1 book - Part 69 of 180
The Ring programming language version 1.5.1 book - Part 69 of 180Mahmoud Samir Fayed
 
The Ring programming language version 1.9 book - Part 98 of 210
The Ring programming language version 1.9 book - Part 98 of 210The Ring programming language version 1.9 book - Part 98 of 210
The Ring programming language version 1.9 book - Part 98 of 210Mahmoud Samir Fayed
 
The Ring programming language version 1.2 book - Part 78 of 84
The Ring programming language version 1.2 book - Part 78 of 84The Ring programming language version 1.2 book - Part 78 of 84
The Ring programming language version 1.2 book - Part 78 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31Mahmoud Samir Fayed
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptxEpsiba1
 
The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 Mahmoud Samir Fayed
 
The Ring programming language version 1.4.1 book - Part 29 of 31
The Ring programming language version 1.4.1 book - Part 29 of 31The Ring programming language version 1.4.1 book - Part 29 of 31
The Ring programming language version 1.4.1 book - Part 29 of 31Mahmoud Samir Fayed
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basicsvamshimahi
 

Similar to The Ring programming language version 1.5.2 book - Part 69 of 181 (20)

The Ring programming language version 1.8 book - Part 79 of 202
The Ring programming language version 1.8 book - Part 79 of 202The Ring programming language version 1.8 book - Part 79 of 202
The Ring programming language version 1.8 book - Part 79 of 202
 
The Ring programming language version 1.9 book - Part 83 of 210
The Ring programming language version 1.9 book - Part 83 of 210The Ring programming language version 1.9 book - Part 83 of 210
The Ring programming language version 1.9 book - Part 83 of 210
 
The Ring programming language version 1.4 book - Part 20 of 30
The Ring programming language version 1.4 book - Part 20 of 30The Ring programming language version 1.4 book - Part 20 of 30
The Ring programming language version 1.4 book - Part 20 of 30
 
The Ring programming language version 1.3 book - Part 56 of 88
The Ring programming language version 1.3 book - Part 56 of 88The Ring programming language version 1.3 book - Part 56 of 88
The Ring programming language version 1.3 book - Part 56 of 88
 
The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180The Ring programming language version 1.5.1 book - Part 70 of 180
The Ring programming language version 1.5.1 book - Part 70 of 180
 
The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210The Ring programming language version 1.9 book - Part 85 of 210
The Ring programming language version 1.9 book - Part 85 of 210
 
The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189The Ring programming language version 1.6 book - Part 76 of 189
The Ring programming language version 1.6 book - Part 76 of 189
 
The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84The Ring programming language version 1.2 book - Part 53 of 84
The Ring programming language version 1.2 book - Part 53 of 84
 
The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196The Ring programming language version 1.7 book - Part 78 of 196
The Ring programming language version 1.7 book - Part 78 of 196
 
The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212The Ring programming language version 1.10 book - Part 86 of 212
The Ring programming language version 1.10 book - Part 86 of 212
 
Lecture 5.pptx
Lecture 5.pptxLecture 5.pptx
Lecture 5.pptx
 
The Ring programming language version 1.5.1 book - Part 69 of 180
The Ring programming language version 1.5.1 book - Part 69 of 180The Ring programming language version 1.5.1 book - Part 69 of 180
The Ring programming language version 1.5.1 book - Part 69 of 180
 
The Ring programming language version 1.9 book - Part 98 of 210
The Ring programming language version 1.9 book - Part 98 of 210The Ring programming language version 1.9 book - Part 98 of 210
The Ring programming language version 1.9 book - Part 98 of 210
 
The Ring programming language version 1.2 book - Part 78 of 84
The Ring programming language version 1.2 book - Part 78 of 84The Ring programming language version 1.2 book - Part 78 of 84
The Ring programming language version 1.2 book - Part 78 of 84
 
The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31The Ring programming language version 1.4.1 book - Part 20 of 31
The Ring programming language version 1.4.1 book - Part 20 of 31
 
class as the basis.pptx
class as the basis.pptxclass as the basis.pptx
class as the basis.pptx
 
The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180 The Ring programming language version 1.5.1 book - Part 174 of 180
The Ring programming language version 1.5.1 book - Part 174 of 180
 
Codemotion 2015 spock_workshop
Codemotion 2015 spock_workshopCodemotion 2015 spock_workshop
Codemotion 2015 spock_workshop
 
The Ring programming language version 1.4.1 book - Part 29 of 31
The Ring programming language version 1.4.1 book - Part 29 of 31The Ring programming language version 1.4.1 book - Part 29 of 31
The Ring programming language version 1.4.1 book - Part 29 of 31
 
Object oriented basics
Object oriented basicsObject oriented basics
Object oriented basics
 

More from Mahmoud Samir Fayed

The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212Mahmoud Samir Fayed
 
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212Mahmoud Samir Fayed
 

More from Mahmoud Samir Fayed (20)

The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212The Ring programming language version 1.10 book - Part 212 of 212
The Ring programming language version 1.10 book - Part 212 of 212
 
The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212The Ring programming language version 1.10 book - Part 211 of 212
The Ring programming language version 1.10 book - Part 211 of 212
 
The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212The Ring programming language version 1.10 book - Part 210 of 212
The Ring programming language version 1.10 book - Part 210 of 212
 
The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212The Ring programming language version 1.10 book - Part 208 of 212
The Ring programming language version 1.10 book - Part 208 of 212
 
The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212The Ring programming language version 1.10 book - Part 207 of 212
The Ring programming language version 1.10 book - Part 207 of 212
 
The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212The Ring programming language version 1.10 book - Part 205 of 212
The Ring programming language version 1.10 book - Part 205 of 212
 
The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212The Ring programming language version 1.10 book - Part 206 of 212
The Ring programming language version 1.10 book - Part 206 of 212
 
The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212The Ring programming language version 1.10 book - Part 204 of 212
The Ring programming language version 1.10 book - Part 204 of 212
 
The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212The Ring programming language version 1.10 book - Part 203 of 212
The Ring programming language version 1.10 book - Part 203 of 212
 
The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212The Ring programming language version 1.10 book - Part 202 of 212
The Ring programming language version 1.10 book - Part 202 of 212
 
The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212The Ring programming language version 1.10 book - Part 201 of 212
The Ring programming language version 1.10 book - Part 201 of 212
 
The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212The Ring programming language version 1.10 book - Part 200 of 212
The Ring programming language version 1.10 book - Part 200 of 212
 
The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212The Ring programming language version 1.10 book - Part 199 of 212
The Ring programming language version 1.10 book - Part 199 of 212
 
The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212The Ring programming language version 1.10 book - Part 198 of 212
The Ring programming language version 1.10 book - Part 198 of 212
 
The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212The Ring programming language version 1.10 book - Part 197 of 212
The Ring programming language version 1.10 book - Part 197 of 212
 
The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212The Ring programming language version 1.10 book - Part 196 of 212
The Ring programming language version 1.10 book - Part 196 of 212
 
The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212The Ring programming language version 1.10 book - Part 195 of 212
The Ring programming language version 1.10 book - Part 195 of 212
 
The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212The Ring programming language version 1.10 book - Part 194 of 212
The Ring programming language version 1.10 book - Part 194 of 212
 
The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212The Ring programming language version 1.10 book - Part 193 of 212
The Ring programming language version 1.10 book - Part 193 of 212
 
The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212The Ring programming language version 1.10 book - Part 192 of 212
The Ring programming language version 1.10 book - Part 192 of 212
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsAndrey Dotsenko
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 

Recently uploaded (20)

The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 

The Ring programming language version 1.5.2 book - Part 69 of 181

  • 1. Ring Documentation, Release 1.5.2 58.1 The Designer Windows • Toolbox : To select controls to be added to the window. • Properties : To set the properties of the active window or controls. • Design Region : To select, move and resize the window and the controls. 58.2 The Toolbox We have many buttons. • Lock : We can use it to draw many controls of the same type quickly. • Select : We can use it to select a control in the Design Region • Controls Buttons : Select a control to be added to the window. 58.3 The Properties • When we select the window or one control, We will have the selected object properties. • Also In the properties window we have a combobox to select the active control. • Some properties provide a button next to the property value. We can click on the button to get more options. • When we select more than one control, We will have options for multi-selection 58.1. The Designer Windows 655
  • 2. Ring Documentation, Release 1.5.2 58.4 Running Forms When we save the form file (*.rform), The Form Designer will create two Ring files • The Controller Class • The View Class For example, if the form file is helloworld.rform The form designer will generate two files • helloworldcontroller.ring • helloworldview.ring To run the program, Open the controller class file then click the Run button (CTRL+F5) Tip: When you open a form using Ring Notepad, the controller class will be opened automatically, So we can press (CTRL+F5) or click on the Run button while the form designer window is active. 58.5 Events Code 1. Just type the method name in the event property. 58.4. Running Forms 656
  • 3. Ring Documentation, Release 1.5.2 (2) Then write the method code in the controller class. 58.5. Events Code 657
  • 4. Ring Documentation, Release 1.5.2 In this example we write func CloseWindow oView.win.close() Where inside the controller class, We uses the oView object to access the form. Another Example : 58.5. Events Code 658
  • 5. Ring Documentation, Release 1.5.2 The Event Code func SayHello oView { LineEdit2.setText("Hello "+ LineEdit1.text() ) } 58.6 Keyboard Shortcuts After selecting one or group of controls • Use the Arrows (Up, Down, Left and Right) to move them around. • Shift + the Arrows (Up, Down, Left and Right) to Resize the controls. • Del button to delete the controls. • CTRL+SHIFT+V to Duplicate the controls. 58.7 Menubar Designer From the Window properties we can open the Menubar Designer 58.6. Keyboard Shortcuts 659
  • 6. Ring Documentation, Release 1.5.2 58.8 Window Flags From the Window properties we can open the Window Flags window. 58.8. Window Flags 660
  • 7. Ring Documentation, Release 1.5.2 58.9 Entering Items For some controls like the List Widget we can enter items separated by comma ‘,’ 58.10 Using Layouts 1. To use layouts, At first add the layout control to the window. 2. Use the window “Set Layout” property to determine the main layout. 3. From the layout properties determine the controls and the layout type. 58.11 More Samples and Tests Check the folder : ring/applications/formdesigner/tests Online : https://github.com/ring-lang/ring/tree/master/applications/formdesigner/tests 58.9. Entering Items 661
  • 8. CHAPTER FIFTYNINE SCOPE RULES FOR VARIABLES AND ATTRIBUTES In this chapter we will learn about scope rules and how Ring find variables. Also we will learn about conflicts and how to solve/avoid them. The next information are important once you start developing large applications using Ring These application may uses • Global variables (Try to avoid them) • Classes (Object-Oriented) • braces { } to access objects • Declarative Programming • Natural Programming 59.1 Three Scopes In Ring we have three scopes :- 1. Public/Global Scope - Each variable you define in the statements part (before functions and classes) 2. Object Scope - When you are inside an object (Inside class method or using { } to access the object ) 3. Local Scope - Related to functions and methods 59.2 Defining Variables and Variables Access 1. Ring uses lexical scoping, i.e. the scope of the variable is based on where we defined the variable. 2. Inside braces { } when you access an object, You will change the current active object scope to this object scope but you still can access the global scope and the local scope. 3. After the ‘Class’ keyword and the class name, when you write variable names to be defined as attributes, You still can access the global scope. In this region (class region - after the class name and before methods) we have • Global Scope —-> The Global Scope • Object Scope —-> The Object Scope • Local Scope —-> The Object Scope 662
  • 9. Ring Documentation, Release 1.5.2 Note: Since the local scope in the class region point also to the object scope in this region, we can use nested braces and still have access to the object scope of the class through the local scope. Tip: You can create windows and controls as attibutes by defining them in this region. Tip: In the class region if you created objects and used braces {} to access them then using self.attribute inside braces will use the class (not the object that you access) because you have access to the class through the local scope. 4. Function Parameters are automatically defined in the local scope. 59.3 How Ring find the variable? 1 - Search First in the Local Scope if not found ! 2 - Search in the Object Scope if not found ! 3 - Search in the public scope if not found —-> Runtime Error if found —-> Check if we can do optimization to avoid searching next time (Cache / Pointers for performance). 59.4 Using Object.Attribute When we use object.attribute the search will be in the object attributes only. I.e. no search will be done in the local scope or in the global scope for the object attribute. Note: Using self.attribute will search for the first self before searching for attributes. 59.5 The Self Object The self object is a reference to the current object that we can use from the class methods. When we are inside class method and use Self we mean the object that will be created from this class. Inside the class methods if we used Braces { } this will change the current object scope and self will be changed also inside braces to reference the object that we access using Braces. Inside the Class Region (after the class name and before any method) we have access to the object through the object scope and the local scope also. In this region using Self will always be a reference to the class object. if we used Braces to change the object scope then used Self inside Braces, Also self will be a reference to the class object (not the object that we already access using braces) because in the class region we have :- • Global Scope —> Global Scope • Object Scope —> Object Scope 59.3. How Ring find the variable? 663
  • 10. Ring Documentation, Release 1.5.2 • Local Scope —> Object Scope And using Braces changes the object scope only (not the local scope) and when Ring search for variables it will search in the Local Scope first so it will find self in the class that we are inside. 59.6 How Ring Define Variables and Attributes Ring will use the variable name in the Assignment operation 1 - Search using the variable name 2 - If not found —> Avoid the runtime error and define the variable in the current scope 3 - If found —> Use the variable and don’t define anything in the current scope • In the global region (before any function or class) the current scope is the global scope. • In the class region (after the class name and before any method) the current scope is the object attributes. • In Functions and methods the current scope is the local scope. 59.7 Conflict between Global Variables and Class Attributes Look at this example: name = "test" o1 = new person see o1 class person name address phone In the previous example we have a global variable called ‘name’ inside the class person. when we use the variable ‘name’, Ring will start the search operation and will try to find it. if found —> Use it if not found —> Define new attribute But the variable name is a global variable, so it will be found and used! We will not have the attribute name! added to the object. Solution (1) - Use the Main Function func main name = "test" o1 = new person see o1 class person name address phone Solution (2) - Use special mark for global variable names like $ 59.6. How Ring Define Variables and Attributes 664