Programming
Basic shell programming introduction
we're going to start off by writing our first shell script. First of all fire up your favourite text editor.If you're not sure what a text editor is or what text editor you should use,then take a look at these ones.By default if you're running the gnome desktop you should have pre-installed version of gedit.Other well known text editors include...kwrite, emacs, vi,tea, kedit, to name but a few.
Ok type this into your text editor..........................................
#!/bin/bash
# test script
echo "running my first test script"
*Now save your file as testscript.
The first line of the program tells us which program will interpret this script.So for this case it'll be /bin/bash The second line is just a comment and everything that appears after # is ignored.
In the last line you'll see the echo command, this simply is just a print command. And it will print out the words "running my first test script"
Setting permisions
The next thing we need to do is to give the shell permision to execute the script.We can acheive this by using the chmod command.
Simply type this into your terminal................. chmod 755 testscript.
Then press enter, next type into your terminal this......... ./testscript "and hit enter"
The output you should see in your terminal should be this........ running test script
Congratulations, you've just written and executed your first shell script!
A further note on permisions, 755 = gives read write and execute permissions
If you want your script to be private, which means only you can read and execute it. Then type in 700 instead.
Mark.
Basic shell commands
RealBasic
REALbasic is a rapid application development (RAD) environment that provides developers a marked increase in productivity over other cross-platform development tools. REALbasic includes drag-and-drop capability to enable you to quickly create a user interface design, then incorporate the code behind it to add power and functionality.
Migrate Visual Basic applications to Linux and Mac OS X
REALbasic is highly compatible with Visual Basic, so Visual Basic developers are productive very quickly with REALbasic. REALbasic also comes with a utility to help convert Visual Basic projects to REALbasic where they can be compiled for Windows, Mac, even Linux -- with the click of a checkbox.
Create native cross-platform software
REALbasic 2007 runs on and creates software for Windows 98, NT, ME, 2000 and XP, Mac OS X and Linux, all from a single set of source code. REALbasic incorporates platform-specific intelligence, like user interface widgets, so software created with REALbasic looks and feels native, regardless of the development platform you created it on.
Create powerful database applications
Build powerful database applications with REALbasic's built-in REAL SQL Database, based on the SQLite public domain database engine. Connect to external multi-user database engines using REALbasic Professional Edition.
Create graphics for multimedia applications or games
Use REALbasic's support for standard image formats for vector graphics, (such as those commonly created with Adobe Illustrator). Use REALbasic's Real-time 3D Engine to add interactive real-time rendered three-dimensional graphics with built-in tools. Also, use REALbasic's Sprite Animation Engine to develop interactive sprite surfaces with collision detection already built-in.
From realbasic.com
Realbasic programming tutorials
Ok in these tutorials we're going to be looking at creating a few basic programs.First off get your ass over to realbasic. com and download realbasic for your particular platform! You can write applications for Linux, mac and windows using this suite, pretty neat heh?
Tutorial 1 what's my name?
1. open up the real basic and double click on window1 which you should see, this will take you through into another window. You'll see a form/window ready for you to start work on.To the left you'll see a toolbox, with various widgets in it, pushbutton, editfield, etc. These can either be double clicked on or dragged on to your window.
2.First off , drag or double click on editfield in your toolbox, then the same with pushbutton, statictext. Now you should be able to see a pushbutton, statictext box + an editfield all on your window.
3Arrange these any way you want. If you check the properties window on the right hand side you'll see that all of these have their own properties which you can altar.
4. Start with editfield.............. single click on it and change it's name property to "text1"
ok next......... single click on the pushbutton and change it's name property to "button1"
and finally........single click on the statictext box and change it's name to "sttext1"
5. No single click on your button1 and look in your properties window.Scroll down until you see it's caption property. Change it's caption property to "Enter" and then click on run to run your program. You'll be able to see your what your program looks like at runtime.
6. Go back to your form and double click on button1, this'll bring up a code window where you can put your code into. Type the following code into it...............................
dim name as string
name = text1.text
sttext1.text = text1.text
7. Ok run the program and type your name into the text box then click enter, you'll then see your name displayed in the sttext1 box :-) Pretty good for just a few lines of code heh?
Mark.
Let's take our program a step forward
We've seen what we can do with a few objects and a couple of lines of code. Now open your project, which I hope you saved from last time.
Ok when we click our button we see the name appear in the static text box below right? So have a look at the text box above. Do you notice anything? Yes the name is still in the box, and we don't want that do we? So we're going to insert a line of code which will remedy this problem!
In your pushbutton just insert this line of code below the sttext1 line.
text1.text = ""
What does this line of code do? Well it'll clear anything that was previously in the text box!
We have another minor problem now, can you spot it? Well if you said the colour on my form is pink, then you deserve a poke up the bum with a red hot iron! If however you spotted that there is no focus in the text box, you'd be correct! So how do we get the focus back? Under your text1.text = "" line, insert this line of code..............
text1.setfocus
Now run your program again! Voila the focus should be in the text box!
Mark.
Clearing our name from the static text box
So how do you get rid of the text that has appeared in the static text box below? First put a new pushbutton onto your window, then in the properties window, change it's name to button2 and it's apperance caption to clear text.
Then double click on the button and add this code into the window.
sttext1.text = ""
yes you should remember the code from the last part. This code will clear any text from the box. Go ahead try it!
Now add another pushbutton to your form, place it at the bottom right hand side. Then name it button3 and it's caption property to Exit!Double click on the button and in the code window type in this code.............................................
window1.close
Now run the program, and click on the exit button, what happens? wow it closes the program! With just that one line of code.
Nearly forgot, we need to call our program something, so double click on the form / window and it'll bring you to the windows code section. Now type this in..................
self.title = " my program"
Now run your program and look at it's name "my program :-)
If.....then.....else
How does a computer make a decision? Well one method is to use the if/then/else clause. We're going to modify our previous program to incorporate this new language.
Open your previously saved program and double click on the enter button to bring up the code window. Then enter the new code, when all is finished your code window should look like this.
dim name as string
name = text1.text
sttext1.text = text1.text
if name = "mark" then
sttext1.text = ""
msgbox "hi mark"
else
sttext1.text = ""
msgbox "who are you"?
end if
text1.text = ""
text1.setfocus
Now lets take a closer look at the code we've just used.
if name = "mark" then....(if the name is equal to mark then)
sttext1.text = "" (statictextbox is empty)
msgbox "hi mark" (message box says hi mark)
end if (end the block of code)
text1.text = "" (text1 box is clear)
text1.setfocus (focus is set back to text1)
Mark.