Information Computer

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Thursday, January 5, 2012

Conversion Integer to String [QtCreator]

in the programming world is certainly very important variable. and the variable whose name is very close to the data type. in some programming language is very sensitive to the type of data.

in this post I discuss Integer and string data types. integer data type is a data type for data in the form of integers. while the string data type is a data type for data in the form of text. string data type could be worth number, but can not be calculated as arithmetic. therefore the data must first be converted to an Integer data type.

this time we try to convert the data type Integer to String and vice versa in QtCreator. follow the following steps.

1. The first example we created a variable of type int named number
int var_number = 6;

2. now convertible into QString way.
QString var_str_number= QString::number(var_number);

3. after that follows the example if you want to be converted again to the numbers.
int var_number_again = var_str_number.toint();

any question?? please comment above. good luck :)


need to know! 
Qt Creator is a cross-platform C++ integrated development environment which is part of the Qt SDK. It includes a visual debugger and an integrated GUI layout and forms designer. The editor's features includes syntax highlighting and autocompletion, but not tabs. Qt Creator uses the C++ compiler from the GNU Compiler Collection on Linux and FreeBSD. On Windows it can use MinGW or MSVC with the default install and can also use cdb when compiled from source.
READ MORE >> Conversion Integer to String [QtCreator]

Sunday, January 1, 2012

Make Application In Qt Creator (Ubuntu)

First step : Install Qt Cretor
- sudo apt-get install qtcreator (in terminal)
- or install using ubuntu software center

Second step : Make a New Project
- click Create Project
- choose Qt4 GUI Application, then click ok
- fill Name with name of the project that you create
- Create in is location you will save the project
- Then click Next

Third step : Desain Interface
- to design applications, we enter the editor and double-click mainwindow.ui adding components with drag 'n drop components to the form.
- in this tutorial we need :
   ~ 2 spin box
   ~ 2 Labels
   ~ 1 Push Button
- double-click to edit caption
- to change property of object, we look at side panel

Fourth step : Give Code
- to Give code we click-right object, click go to slot then choose event.
- so we click-right Push Button, Click go to slot then choose clicked()
- give code below MainWindow::on_pushbutton_clicked().

qint8 result= ui­>spinbox­>value() + ui­>spinbox_2­>value();
QString resultString=QString::number(result);
ui­>label­>setText(resultString);

Fiveth step : Running application
- save (CTRL + S)
- run (CTRL + R or F5)


need to know! 
Qt Creator is a cross-platform C++ integrated development environment which is part of the Qt SDK. It includes a visual debugger and an integrated GUI layout and forms designer. The editor's features includes syntax highlighting and autocompletion, but not tabs. Qt Creator uses the C++ compiler from the GNU Compiler Collection on Linux and FreeBSD. On Windows it can use MinGW or MSVC with the default install and can also use cdb when compiled from source.
READ MORE >> Make Application In Qt Creator (Ubuntu)

Monday, August 15, 2011

PHP Date Function

While waiting for iftar. I want to continue post yesterday describing the functions of PHP. if yesterday we had know about the PHP string functions. Now we will discuss about the PHP date function.

Date function is used to retrieve the value in the date, hour, and all the things about the current time. The results of this function is a string which contains the date / hour according to the desired format. following the existing format in date function

a - "am" or "pm"
A - "AM" or "PM"
B - Swatch Internet time
d - day of the month, 2 digits with leading zeros; i.e. "01" to "31"
D - day of the week, textual, 3 letters; i.e. "Fri"
F - month, textual, long; i.e. "January"
g - hour, 12-hour format without leading zeros; i.e. "1" to "12"
G - hour, 24-hour format without leading zeros; i.e. "0" to "23"
h - hour, 12-hour format; i.e. "01" to "12"
H - hour, 24-hour format; i.e. "00" to "23"
i - minutes; i.e. "00" to "59"
I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
j - day of the month without leading zeros; i.e. "1" to "31"
l (lowercase 'L') - day of the week, textual, long; i.e. "Friday"
L - boolean for whether it is a leap year; i.e. "0" or "1"
m - month; i.e. "01" to "12"
M - month, textual, 3 letters; i.e. "Jan"
n - month without leading zeros; i.e. "1" to "12"
s - seconds; i.e. "00" to "59"
S - English ordinal suffix, textual, 2 characters; i.e. "th", "nd"
t - number of days in the given month; i.e. "28" to "31"
T - Timezone setting of this machine; i.e. "MDT"
U - seconds since the epoch
w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday)
Y - year, 4 digits; i.e. "1999"
y - year, 2 digits; i.e. "99"
z - day of the year; i.e. "0" to "365"
Z - timezone offset in seconds (i.e. "-43200" to "43200")

sintax :

date (string format)

examples of the use of date functions :

date ("Ymd"); / / prints "2011-08-15"
date ("l, j FY"); / / prints "Monday, 15 August 2011"
date ("H: i: s"); / / prints "16:51:06"

very simple and very useful to complement your web page. may be useful for you. thank:)

need to know! 
In computer science, a subroutine (also called procedure, function, routine, method, or subprogram) is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code.

As the name "subprogram" suggests, a subroutine behaves in much the same way as a computer program that is used as one step in a larger program or another subprogram. A subroutine is often coded so that it can be started ("called") several times and/or from several places during a single execution of the program, including from other subroutines, and then branch back (return) to the next instruction after the "call" once the subroutine's task is done.

Subroutines are a powerful programming tool, and the syntax of many programming languages includes support for writing and using them. Judicious use of subroutines (for example, through the structured programming approach) will often substantially reduce the cost of developing and maintaining a large program, while increasing its quality and reliability. Subroutines, often collected into libraries, are an important mechanism for sharing and trading software. The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).

In the compilation technique called threaded code, the executable program is basically a sequence of subroutine calls. Maurice Wilkes, David Wheeler, and Stanley Gill are credited with the invention of this concept, which they referred to as closed subroutine
READ MORE >> PHP Date Function

Sunday, August 14, 2011

PHP String Fungtions

how are you? hopefully fine. due to the following post I will discuss about the functions of a string in PHP. functions in PHPfunctions I will post it here. following functions are string functions that are often used.

string functions are the functions used to manipulate a string for a particular purpose. The following is a PHPstring functions.
  1. Addslash
    • Used to add a backslash character (\) on a string.It aims to use the query string to the database. examples of characters that need to be backslash (\) is the single quotes ('), two quotation marks ("), marks a backslash (\), and the null character.
    • sintax : addslash(string)
  2. Stripslash
    • Used to remove the backslash character (\) on a string.
    • sintax : stripslash(string)
  3. Crypt
    • Used to encrypt the DES method of a string. use of the crypt function can be added to a string parameter 'salt'. was added to determine the basis of randomization. If the 'salt' string is not added to the PHP crypt function will determine its own 'salt' is a random string.
    • sintax : crypt(string [, salt])
  4. Echo
    • Used to print the contents of a string or argument.
    • sintax : echo string
  5. Explode
    • Used to break up a string based on a specific list separator and put the result into a variable array
    • sintax : explode (separator string, string [, integer limit])
  6. Implode
    • used to generate a string from each of the elements of an array. The resulting string is separated by a string has been determined previously.
    • sintax : implode (separator string, array)
  7. StripTags
    • Used to remove the code in a string of HTML tags.
    • sintax : striptags (string [,string exceptions])
  8. StrLen
    • Used to calculate the number of characters of a string.
    • sintax : strlen (string)
  9. StrPos
    • Used to find the first position of a sub string in a string. This function is typically used to search a sub string within a string.
    •  sintax : strpos(string, sub string)
  10. Str_Repeat
    • Used to repeat the content of a string.
    • sintax : str_repeat(string , number of repetitions)
  11. StrToLower
    • Used to convert a string to lowercase
    • sintax : strtolower(string)
  12. StrToUpper
    • Used to convert a string to uppercase
    • sintax : strtoupper(string)
  13. SubStr
    • Used to retrieve a sub-string with a certain length of a string at a particular position as well.
    • sintax : substr(string , integer start position, integer end position)
  14. SubStr_Count
    • Used to calculate the number of substring in a string.
    • sintax : substr_count(string , string substring)
  15. UCFirst
    • Used to replace the first character in a string to uppercase.
    • sintax : ucfirst(string)
  16. UCWord
    • Used to replace the first character of each word in a string to uppercase.
    • sintax : ucword(string)
thank :)

need to know! 
In computer programming, a string is traditionally a sequence of characters, either as a literal constant or as some kind of variable. The latter may allow its elements to be mutated and/or the length changed, or it may be fixed (after creation). A string is generally understood as a data type and is often implemented as a byte (or word) array that stores a sequence of elements, typically characters, using some character encoding. A string may also denote more general array data types and/or other sequential data types and structures; terms such as byte string, or more general, string of datatype, or datatype-string, are sometimes used to denote strings in which the stored data does not (necessarily) represent text.

Depending on programming language and/or precise datatype used, a variable declared to be a string may either cause storage in memory to be statically allocated for a predetermined max length or employ dynamic allocation to allow it to hold chronologically variable number of elements. When a string appears literally in source code, it is known as a string literal and has a representation that denotes it as such.
READ MORE >> PHP String Fungtions

Saturday, August 13, 2011

Connect PHP With MySQL

The previous post I've described a little about MySQL functions in PHP. Maybe in your previous posts are still confused. Because I was just giving an explanation without an example.Following I will give an example of using the mysql functions in php. So, we will discuss examples of how to connect PHP with MySQL.

The first step we create a file named config.php which serves to connect a PHP file with MySQL.

config.php

<?php
mysql_connect("localhost","root","");
mysql_select_db("data");
?>

note :
"localhost" = hostname MySQL
"root"         = username MySQL
""                = password MySQL (password is not filled)
"data"         = database name

This is the default if you use XAMPP for local web server. Customize to your web server. Next create a file named index.php.

index.php

<?php
include('config.php');
$query= mysql_query("select * from table_data");
$rows = mysql_num_rows($query);
echo "Number of rows = $rows <p>";
while ($result = mysql_fetch_array($query)){
    echo "$result[0]<br>";
}
?>

note :
table_name = table name used (adjust yours).

if successful will appear as shown below




Connect PHP WIth MySQL


I hope this post helpful to us all. sorry if there is one word or a typo. sorry if things go wrong. ask if anyone on this please post a comment below. thank:)
READ MORE >> Connect PHP With MySQL

Monday, August 8, 2011

Mysql Functions In PHP

Earlier we know that PHP has a good connectivity to multiple databases. one of them with MySQL. because in PHP has several functions that are used to MySQL. The following functions.

mysql_connect (Host, Username, Password)
used to connect MySQL database with PHP files.
example : $var = mysql_connect("localhost","root","password").

mysql_close (variable_open_mysql)
used to close the MySQL database connection with PHP files.
example : mysql_close($var).

mysql_select_db(database name)
used to select the database that is used.
example : mysql_select_db("database").

mysql_query(query)
used to run a query.
example : $q = mysql_query("select * from data").

mysql_num_row(variable_query)
used to determine the number of rows in the result of a query.
example : $row = mysql_num_row($q).

mysql_fetch_array(query)
used to display the results of a query in the form of an array.
example : $result = mysql_fetch_array($q).

This new course may be necessary to be submitted. actually there are still others that I have not convey. therefore when the time comes I will update this article. thank :)

need to know! 
In computer science, a subroutine (also called procedure, function, routine, method, or subprogram) is a portion of code within a larger program that performs a specific task and is relatively independent of the remaining code.

As the name "subprogram" suggests, a subroutine behaves in much the same way as a computer program that is used as one step in a larger program or another subprogram. A subroutine is often coded so that it can be started ("called") several times and/or from several places during a single execution of the program, including from other subroutines, and then branch back (return) to the next instruction after the "call" once the subroutine's task is done.

Subroutines are a powerful programming tool, and the syntax of many programming languages includes support for writing and using them. Judicious use of subroutines (for example, through the structured programming approach) will often substantially reduce the cost of developing and maintaining a large program, while increasing its quality and reliability. Subroutines, often collected into libraries, are an important mechanism for sharing and trading software. The discipline of object-oriented programming is based on objects and methods (which are subroutines attached to these objects or object classes).

In the compilation technique called threaded code, the executable program is basically a sequence of subroutine calls. Maurice Wilkes, David Wheeler, and Stanley Gill are credited with the invention of this concept, which they referred to as closed subroutine
READ MORE >> Mysql Functions In PHP

Sunday, August 7, 2011

PHP

PHP stands for "Hypertext Preprocessor". PHP is a server-side scripting language that integrates with HTML to create dynamic web pages. so php is a scripting language that is attached to the HTML that is server-side.

server-side scripting is the syntax and commands given will be completely executed on the server but is included in an HTML document. so the server will run and process the PHP file and the browser will display a HTML file. so users will not be able to see the PHP program code and the security of a web page to be more secure

advantages and capabilities of PHP.
  1. Open Source (Free).
  2. With multiple OS support.
  3. Can send the HTTP header.
  4. May set cookies.
  5. set authentication and redirect users.
  6. good connectivity to multiple databases, such as
    • Oracle
    • Sybase
    • mSQL
    • MySQL
    • Solid
    • PostgreSQL
    • Adabas
    • File.Pro
    • Velocis
    • dBase
    • Unix dbm
  7. can integrate with several external libraries
  8. supports communication with other services
There are several ways to start writing PHP scripts.
  1. <?php Script PHP ?>
  2. <? Script PHP ?>
  3. <% Script PHP %>
  4. <script language=PHP>Script PHP</script>

Asked if there is please leave a message on this post. thank you for your attention :)

need to know! 
Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the web server to generate dynamic web pages. It is usually used to provide interactive web sites that interface to databases or other data stores. This is different from client-side scripting where scripts are run by the viewing web browser, usually in JavaScript. The primary advantage to server-side scripting is the ability to highly customize the response based on the user's requirements, access rights, or queries into data stores.

From a security point of view, server-side scripts are never visible to the browser as these scripts are executed on the server and emit HTML corresponding to user's input to the page.

When the server serves data in a commonly used manner, for example according to the HTTP or FTP protocols, users may have their choice of a number of client programs (most modern web browsers can request and receive data using both of those protocols). In the case of more specialized applications, programmers may write their own server, client, and communications protocol, that can only be used with one another.

Programs that run on a user's local computer without ever sending or receiving data over a network are not considered clients, and so the operations of such programs would not be considered client-side operations..
READ MORE >> PHP

Friday, August 5, 2011

JavaScript PopUp Window

sometimes if we create a web we will need something called a popup window. popup window is used to bring up a web page in a new window whose size can be set. we can make a popup using javascript. The following source code to create a popup window with javascript.

Create a file with the name index.php

<html>
<head>
<title>PopUp Window</title>
<script>
function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page"+id+"=window.open(URL,'"+id+"', 'toolbar=0, scrollbars=0, location=0, statusbar=0, menubar=0, resizable=0, width=250, height=250, left =304,top = 150.5');");
}
</script>
</head>
<body>
<a href="javascript:popUp('popup.html')">popup</a>
</body>
</html>

nb : for green text should be in a row (do not use the enter key).

then make more of a web page for pages that appear in a popup window with the name popup.html .

<html>
<head>
<title>popup</title>
</head>
<body>
PopUp Window
</body>
</html>

That simple example of using a popup window with javascript. may be useful. thank :)


need to know! 
Pop-up ads or pop-ups are a form of online advertising on the World Wide Web intended to attract web traffic or capture email addresses. Pop-ups are generally new web browser windows to display advertisements. The pop-up window containing an advertisement is usually generated by JavaScript, but can be generated by other means as well.

A variation on the pop-up window is the pop-under advertisement, which opens a new browser window hidden under the active window. Pop-unders do not interrupt the user immediately and are not seen until the covering window is closed, making it more difficult to determine which web site opened them.
READ MORE >> JavaScript PopUp Window

Thursday, August 4, 2011

ASCII Code With JavaScript

this time I will try to explain about how to find the ASCII code keyboard with javascript. so when we typed one key on the keyboard will display a message box that displays the number or the ASCII code of the key. I'll give the source code of a simple javascript. for more details, please see the source code.

<head>
<script LANGUAGE="JavaScript">
function tampil(e)
{
alert(e.keyCode);
}
</script>
</head>
<body onload='document.getElementById("nama").focus()'>
<label>type here :</label>
<input type="text" id="nama" size="15" onKeyUp="tampil(event);"><br>
</body>

that's the way to find out the ASCII code of the keyboard keys we press with JavaScript. ask if anyone in the written comments below. thank :)

need to know! 
The American Standard Code for Information Interchange (ASCII) is a character-encoding scheme based on the ordering of the English alphabet. ASCII codes represent text in computers, communications equipment, and other devices that use text. Most modern character-encoding schemes are based on ASCII, though they support many more characters than ASCII does.

US-ASCII is the Internet Assigned Numbers Authority (IANA) preferred charset name for ASCII.

Historically, ASCII developed from telegraphic codes. Its first commercial use was as a seven-bit teleprinter code promoted by Bell data services. Work on ASCII formally began on October 6, 1960, with the first meeting of the American Standards Association's (ASA) X3.2 subcommittee. The first edition of the standard was published during 1963, a major revision during 1967, and the most recent update during 1986. Compared to earlier telegraph codes, the proposed Bell code and ASCII were both ordered for more convenient sorting (i.e., alphabetization) of lists and added features for devices other than teleprinters.

ASCII includes definitions for 128 characters: 33 are non-printing control characters (now mostly obsolete) that affect how text and space is processed; 95 are printable characters, including the space, which is considered an invisible graphic. The most commonly used character encoding on the World Wide Web was US-ASCII until December 2007, when it was surpassed by UTF-8.
READ MORE >> ASCII Code With JavaScript

Tuesday, August 2, 2011

Ajax Javascript

May still be many who do not know what it was ajax. I think ajax is a web-based programming techniques used to create an interactive web application. Ajax is a combination of server side scripting and client side scripting. so ajax is some combination of Web programming such as javascript, PHP, DOM, HTML, and others.

ajax point will update the contents of a web without reloading process. ajax will do so working in an asynchronous data exchange. please note the exchange of data has 2 post and get methods. ajax script this time using two methods. The following examples use the ajax script.

if you try this script at home. Your computer must be installed xampp as a stand-alone server (localhost).

script file index.php

<html>
<head>
<script src=ajax.js></script>
</head>
<body>
<input type=text id=nama >
<input type=submit onclick=kirim("POST") value=POST>
<input type=submit onclick=kirim("GET") value=GET><br>
<div id=hasil />
<body>
</html>

script file ajax.js

var ajax;
if(window.ActiveXObject){
    ajax = new ActiveXObject("MicrosoftXMLHTTP");
}else {
    ajax = new XMLHttpRequest();
}

function proses(metode,url,params,id,output) {
    if (metode == 'POST'){
        ajax.open("POST",url,true);
        ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    }else{
        ajax.open("GET",url+'?'+params,true);
        params = null ;
    }
    ajax.onreadystatechange = function Response(){
        respon =  ajax.responseText;
        obj = document.getElementById(id) ;
        switch(output){
            case 'innerHTML' : obj.innerHTML = respon;
                break ;
        }
    }
    ajax.send(params);
}

function kirim(metode){
    id = "hasil" ;
    output = 'innerHTML' ;
    nama = document.getElementById('nama').value ;
    url = "ajax.php";
    var params = "nama="+escape(nama);

    proses(metode,url,params,id,output);
}

script file ajax.php

<?php
    if(isset($_POST['nama'])){
        $text1 = $_POST['nama'];
        echo $text1." <i>metode post</i>" ;
    }else if(isset($_GET['nama'])){
        $text2 = $_GET['nama'];
        echo $text2." <i>metode get</i>" ;
    }else{
        echo "null";
    }
?>

create a third file, and be simple ajax. thank :)
READ MORE >> Ajax Javascript

Followers