Introduction to Multilingual Retrieval Augmented Generation (RAG)
Ā
The Ring programming language version 1.6 book - Part 74 of 189
1. Ring Documentation, Release 1.6
In the next code for example (from FirstWindowController.ring)
The Open_WindowAndLink() will create an object from the SecondWindowController Class
Then will add the Method : SecondWindow(), IsSecondWindow() Methods to the FirstWindowController Class
Also will add the Method : FirstWindow(), IsFirstWindow() Methods to the SecondWindowController Class
So the SendMessage() method in FirstWindowController class can use the SecondWindow() method to access the
object.
This is more simple than using Last_Window(), Parent() and SetParentObject() methods.
class firstwindowController from windowsControllerParent
oView = new firstwindowView
func OpenSecondWindow
Open_WindowAndLink(:SecondWindowController,self)
func SendMessage
if IsSecondWindow()
SecondWindow().setMessage("Message from the first window")
ok
func setMessage cMessage
oView.Label1.setText(cMessage)
59.4 Open_WindowInPackages() Function
The Open_WindowInPackages() function is the same as Open_Window() but takes an extra list that determine the
packages to import before opening the window.
Syntax:
Open_WindowInPackages(cClassName,aPackagesList)
Example:
The next example from the Form Designer source code, Open the Window Flags window using the
open_windowInPackages() function.
We determine the class name āWindowFlagsControllerā and the packages name.
The Window Flags window uses the FormDesigner and System.GUI packages.
open_windowInPackages(:WindowFlagsController,[
"formdesigner",
"System.GUI"
])
59.5 Objects Library Source Code
The library source code is very simple, You can check the source code ļ¬les
ā¢ https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/objects.ring
ā¢ https://github.com/ring-lang/ring/blob/master/extensions/ringqt/objectslib/subwindows.ring
59.4. Open_WindowInPackages() Function 703
2. CHAPTER
SIXTY
USING THE FORM DESIGNER
In this chapter we will learn about using the Form Designer.
We can run the From Designer from Ring Notepad
From the Menubar in Ring Notepad - View Menu - We can Show/Hide the Form Designer window.
Also we can run the Form Designer in another window.
From the Ring Notepad - Tools Menu - Select the Form Designer.
704
3. Ring Documentation, Release 1.6
60.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.
60.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.
60.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
60.1. The Designer Windows 705
4. Ring Documentation, Release 1.6
60.4 Running Forms
When we save the form ļ¬le (*.rform), The Form Designer will create two Ring ļ¬les
ā¢ The Controller Class
ā¢ The View Class
For example, if the form ļ¬le is helloworld.rform
The form designer will generate two ļ¬les
ā¢ helloworldcontroller.ring
ā¢ helloworldview.ring
To run the program, Open the controller class ļ¬le 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.
60.5 Events Code
1. Just type the method name in the event property.
60.4. Running Forms 706
5. Ring Documentation, Release 1.6
(2) Then write the method code in the controller class.
60.5. Events Code 707
6. Ring Documentation, Release 1.6
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 :
60.5. Events Code 708
7. Ring Documentation, Release 1.6
The Event Code
func SayHello
oView {
LineEdit2.setText("Hello "+ LineEdit1.text() )
}
60.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.
60.7 Menubar Designer
From the Window properties we can open the Menubar Designer
60.6. Keyboard Shortcuts 709
8. Ring Documentation, Release 1.6
60.8 Window Flags
From the Window properties we can open the Window Flags window.
60.8. Window Flags 710
9. Ring Documentation, Release 1.6
60.9 Entering Items
For some controls like the List Widget we can enter items separated by comma ā,ā
60.10 Using Layouts
1. To use layouts, At ļ¬rst 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.
60.11 More Samples and Tests
Check the folder : ring/applications/formdesigner/tests
Online : https://github.com/ring-lang/ring/tree/master/applications/formdesigner/tests
60.9. Entering Items 711
10. CHAPTER
SIXTYONE
SCOPE RULES FOR VARIABLES AND ATTRIBUTES
In this chapter we will learn about scope rules and how Ring ļ¬nd variables.
Also we will learn about conļ¬icts 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
61.1 Three Scopes
In Ring we have three scopes :-
1. Public/Global Scope - Each variable you deļ¬ne 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
61.2 Deļ¬ning Variables and Variables Access
1. Ring uses lexical scoping, i.e. the scope of the variable is based on where we deļ¬ned 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 deļ¬ned 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
712