Pages

C3 Health Services

Visit Official Website 9278982994

Expert Healthcare at Your Doorstep

Tuesday, 29 January 2013

How to Open, Close, Read and Delete a File in Delphi XE2?

How to Open, Close, Read and Delete a File in Delphi XE2?

File Handling is very simple in delphi programming language. Here is a simple delphi program example for file handling. Following delphi program opens, writes and reads a file. After that the file is closed and finally deleted. Opening a file, reading / writing a file and deleting files are very common functionalities used in any delphi application. Following delphi program example for file handling does the same in very simple way.

procedure MyForm.HowToOpenCloseAndDeleteFile;
var
  fileName : string;
  myFile   : TextFile;
  data     : string;
begin

  // Try to open a text file for writing to
  fileName := 'Test.txt';
  AssignFile(myFile, fileName);
  ReWrite(myFile);
 
  // Write to the file
  Write(myFile, 'Hello World');

  // Close the file
  CloseFile(myFile);

  // Reopen the file in read mode
  Reset(myFile);

  // Display the file contents
  while not Eof(myFile) do
  begin
    ReadLn(myFile, data);
    ShowMessage(data);
  end;

  // Close the file for the last time
  CloseFile(myFile);

  // Now delete the file
  if DeleteFile(fileName) then ShowMessage(fileName+' deleted')
  else ShowMessage(fileName+' not deleted');
end;

Friday, 25 January 2013

jQuery Tutorials: Tips and Tricks for Web Developers

jQuery Tutorials: Tips and Tricks for Web Developers

jQuery has made web designing and development very easy. In this jQuery tutorial, some basic points about jQuery are listed like shorthand for jQuery and importance of CDN (Content Delivery Network). We have also covered some cool jQuery tips and tricks which are commonly used while web designing and development like how to disable right click on web browser in a single line of jQuery script, how to get mouse position using jQuery script, how to find which mouse button was clicked and how to efficiently use jQuery selectors? Every web designer and developer should know these basic tips and tricks of jQuery. These are very easy to learn and grasp and also time saving which reduces human efforts.

1. Use shorthand for $(document).ready()

We can write jQuery code like this:

$(document).ready(function()
{
  //Your jQuery code goes here.
})

But there is a shorthand available for above code. This can be rewritten as

$(function ()
{
   //Your jQuery code goes here.
});

2. Always load jQuery framework from Google, Microsoft or jQuery CDN(Content Delivery Network).

CDN provides several advantages:

1. You always use the latest jQuery framework.
2. It reduces the load from your server.
3. It saves bandwidth. jQuery framework will load faster from these CDN.
4. The most important benefit is, it will be cached if the user has visited any site which is using jQuery framework from any of these CDN.

Code to load jQuery Framework from Google CDN


Code to load jQuery Framework from Microsoft CDN

<script  type="text/javascript"
    src="
http://ajax.microsoft.com/ajax/jquery/jquery-1.4.2.min.js">
</script>

Code to load jQuery Framework from jQuery Site(EdgeCast CDN)<script  type="text/javascript"
    src="
http://code.jquery.com/jquery-1.4.2.min.js">
</script>

3. How to disable right click using jQuery?

You can find many java script code snippets to disable right click. But jQuery makes our life easy. Below jQuery code disables the right click of mouse.

Method 1:

$(document).ready(function(){
    $(document).bind("contextmenu",function(e){
        return false;
    });
});

Method 2:

$(document).ready(function(){
    $(document).bind("contextmenu",function(e){
        e.preventDefault();
    });
});

4. How to get mouse cursor position using jQuery?

$(document).ready(function(){
  $(document).mousemove(function(e){
     $('#spnCursor').html("X Axis : " + e.pageX + " Y Axis : " + e.pageY);
  });
});

When the DOM is ready, we listen for mousemove event. Whenever user moves the mouse then this event gets called and we bind the pageX and pageY property to the span element.

5. How to find which mouse button is clicked using jQuery?

If you need to determine which mouse button (Left, Middle or Right) was clicked. jQuery provides mousedown() event, using which we can check which mouse button is clicked. For key or button events, event attribute indicates the specific button or key that was pressed. event.which will give 1, 2 or 3 for left, middle and right mouse buttons respectively. The advantage of using event.which is that it eliminates cross browser compatibility.

$(document).ready(function() {
$('#btnClick').mousedown(function(event){
    switch (event.which) {
        case 1:
            alert('Left mouse button pressed');
            break;
        case 2:
            alert('Middle mouse button pressed');
            break;
        case 3:
            alert('Right mouse button pressed');
            break;
        default:
           break;
    }
});
});

6. How to use jQuery selectors efficiently?

It is pretty important to understand how to write efficient element selection statement. One has to be very careful while jquery selector statement. Below are some tips on how to use your jQuery selectors efficiently.

A. Always try to use ID as selector

You can use ID as selector in jQuery. See below jQuery code.

$("#elmID");

When IDs are used as selector then jQuery internally makes a call to getElementById() method of Java script which directly maps to the element.

When Classes are used as selector then jQuery has to do DOM traversal.So when DOM traversal is performed via jQuery takes more time to select elements. In terms of speed and performance, it is best practice to use IDs as selector.

B. Use class selector with tags

You can use CSS classes as selector. For example, to select elements with "myCSSClass" following jQuery code can be used.

$(".myCSSClass");

As said earlier, when classes are used DOM traversal happens. But there could be a situation where you need to use classes as selector. For better performance, you can use tag name with the class name. See below

$("div.myCSSClass");

Above jQuery code, restricts the search element specific to DIV elements only.

C. Keep your selector simple, don't make it complex

Avoid complex selectors. You should use make your selectors simple, unless required.
$("body .main p#myID em");

Instead of using such a complex selector, we can simplify it. See below:

$("p#myID em");

D. Don't use your selector repeatedly

See below jQuery code. The selectors are used thrice for 3 different operation.

$("#myID").css("color", "red");
$("#myID").css("font", "Arial");
$("#myID").text("Error occurred!");

The problem with above code is, jQuery has to traverse 3 times as there are 3 different statements.But this can be combined into a single statement.

$("p").css({ "color": "red", "font": "Arial"}).text("Error occurred!");
 
E. Know how your selectors are executed

Do you know how the selectors are executed? Your last selectors is always executed first. For example, in below jQuery code, jQuery will first find all the elements with class ".myCssClass" and after that it will reject all the other elements which are not in "p#elmID".

$("p#elmID .myCssClass");

Thursday, 17 January 2013

Best Free XML Editors and Viewers

Best Free XML Editors and Viewers

Here is the list of best free XML Editors and Viewers which will make it easy for you to understand XML. Professional XML editors will help you to write error-free XML documents, validate your XML against a DTD or a schema, and force you to stick to a valid XML structure.
An XML editor should be able to:

1. Add closing tags to your opening tags automatically
2. Force you to write valid XML
3. Verify your XML against a DTD
4. Verify your XML against a Schema
5. Color code your XML syntax

Need of an XML Editor

Today XML is an important technology, and development projects use XML-based technologies like:

1. XML Schema to define XML structures and data types
2. XSLT to transform XML data
3. SOAP to exchange XML data between applications
4. WSDL to describe web services
5. RDF to describe web resources
6. XPath and XQuery to access XML data
7. SMIL to define graphics
8. To be able to write error-free XML documents, you will need an intelligent XML editor!

List of Best Free XML Editors and Viewers

1. XML Notepad

XML Notepad is Microsoft’s contribution to the XML editor forum. Based in class on the popular text editor dispensed with Windows operating systems, Notepad, the XML module offers a semi WYSIWYG design. The tree view and text view are color coded and use bold shapes to identify the elements and their family relationships for XPath navigation. Overall, Microsoft’s XML Notepad is not a terrible choice for those with a basic understanding of XML. Additionally, the program helps design and produce XSL style sheets to accompany the XML information and create an output stream.

2. FOXE XML Editor

First Objective Software Inc. produces a free editor that works as an advanced text editor . FOXE offers some basic tools for authoring code but does not delve too far into styling. The program does provide some inherent code that allows you to navigate files, define XPath information and split documents. This is a decent choice for those learning to take baby steps in XML production. The tree view and embedded scripts make FOXE a better choice than a standard text editor, but the program still makes you work to learn  to write effective XML.

3. Serna Free – Open Source XML Editor

Serna is a WYSIWYG editor produced by Syntext that goes beyond the norm. Like most XML editors, Serna begins with the classic split screen and works exclusively in a WYSIWYG style. It will take some practice to get used to the interface, but once you understand the basic tools, creating your document is straightforward. This is an editor for someone who has a clear understanding of XML technology and looking for a shortcut. Newcomers need to understand the basics of valid XML before attempting to work within the Serna environment..

What is an XML File or XML Document? Why to use XML?

What is an XML File or XML Document? Why to use XML?

This article covers basics of XML. We will discuss some benefits and advantages of XML.

What is XML?

XML is Extensible Markup Language. XML is a specification developed by W3C. XML is a standard, simple, self-describing way of encoding both text and data so that content can be processed with relatively little human intervention and exchanged across diverse hardware, operating systems, and applications.

In brief, XML offers a widely adopted standard way of representing text and data in a format that can be processed without much human or machine intelligence. Information formated in XML can be exchanged across platforms, languages, and applications, and can be used with a wide range of development tools and utilities.

Example of XML Document

<bag label="Glenns Food" storage-date="October, 2001">
  <item>Candy Bar</item>
  <bag label="Vegetables" storage-date="Oct 11 2001">
 <item>Carrot</item>
 <item>Lettuce</item>
  </bag>
  <bag label="Fruits" storage-date="Oct 13 2001">
 <item>Pear</item>
  </bag>
</bag>

Difference between HTML and XML

XML is similar enough to HTML in its actual format. But there are two fundamental differences:

1. Separation of form and content -- HTML mostly consists of tags defining the appearance of text; in XML, the tags generally define the structure and content of the data, with actual appearance specified by a specific application or an associated stylesheet.

2. XML is extensible -- tags can be defined by individuals or organizations for some specific application, whereas the HTML standard tagset is defined by the World Wide Web Consortium (W3C).  

Advantages of XML

1. Simplicity

Information coded in XML is easy to read and understand, plus it can be processed easily by computers.

2. Openness

XML is a W3C standard, endorsed by software industry market leaders.

3. Extensibility

There is no fixed set of tags. New tags can be created as they are needed.

4. Self-description

In traditional databases, data records require schemas set up by the database administrator. XML documents can be stored without such definitions, because they contain meta data in the form of tags and attributes.

XML provides a basis for author identification and versioning at the element level. Any XML tag can possess an unlimited number of attributes such as author or version.

5. Contains machine-readable context information

Tags, attributes and element structure provide context information that can be used to interpret the meaning of content, opening up new possibilities for highly efficient search engines, intelligent data mining, agents, etc.

This is a major advantage over HTML or plain text, where context information is difficult or impossible to evaluate.

6. Separates content from presentation

XML tags describe meaning not presentation. The look and feel of an XML document can be controlled by XSL style sheets, allowing the look of a document (or of a complete Web site) to be changed without touching the content of the document. Multiple views or presentations of the same content are easily rendered.

7. Supports multilingual documents and unicode

This is important for the internationalization of applications.

8. Facilitates the comparison and aggregation of data

The tree structure of XML documents allows documents to be compared and aggregated efficiently element by element.

9. Can embed multiple data types

XML documents can contain any possible data type - from multimedia data (image, sound, video) to active components (Java applets, ActiveX).

10. Can embed existing data

Mapping existing data structures like file systems or relational databases to XML is simple. XML supports multiple data formats and can cover all existing data structures and

11. Provides a 'one-server view' for distributed data

XML documents can consist of nested elements that are distributed over multiple remote servers. XML is currently the most sophisticated format for distributed data - the World Wide Web can be seen as one huge XML database.

Key Features of a Professional Web Design and Development Company

Key Features of a Professional Web Design and Development Company

Today, if you have a business, you must have a website for it. Your website sells your products and services to the whole world. In today's fast-paced, technology-driven business world, it is simply a fact of life that if your business doesn't have an online presence, you're going to have a much harder time succeeding.

Next thing, you don't need only a website but a quality and good looking attractive website. These days your website is your storefront. Just as a run-down storefront can send customers to your competitor across the street, a poorly-designed website can send them to the next Google search result. In other words, you don't just need a website. You need a high-quality website. You need an attractive design with an intuitive layout and well-written content.

So, for having your own business website, you should consult a good website designing and development company. Before giving contract of your business website to any web designing and development company, you must ensure following points:

1. Web Design and Development company must have a recognized name in the web design and development industry.

2. Web Design and Development company must have good experience and knowledge in web design domain. Ask for the previous project samples on which they have worked upon.

3. Always get to know about their clients and customers with which they are dealing. Go through the testimonials their clients have written for them. Always check the track record of the company.

4. Not only web design, also ask for different kind of facilities your web designing and development company should provide you like content management, blog posting, email services, web hosting, social media (twitter, facebook, linkedin) connection tools etc.

5. While giving contract to any web designing and development company, must ensure that you require not only web version of your website but also the mobile version.Today, internet is accessible from mobile also. Don't let your website look obsolete and unstructured on mobile. So, while designing your website, you must ensure that your website should look nice both in web browser and mobile browsers. Also check you website design on various browsers like Firefox, Chrome, IE, Opera, Safari etc.

6. If your website involves some money transaction features, you must get ensured from your web design and development company that they use security certificates and third party certified tools for transactions like amazon and ebay. Instead of http, https should be used in the url of your website.

7. You must have knowledge about SEO (Search Engine Optimization). Always ask your web design and development company that what measure they are taking for Search Engine Optimization. SEO is very important for any website. Always get ensured that the content of your website is targeting the keywords which are searched on search engines like google, yahoo, msn, ask etc.  People these days don't go to their telephone directory to look for local businesses anymore. They go to their computers and search for them. And if your business doesn't come up in your search results, they don't even consider looking for you anywhere else.

8. Internet Marketing is a key concept today in web designing and development market. Your web design and development company should take responsibility for that. Social media marketing on facebook and twitter is very vital for your website.

9. Logo design, PDF creation, Brand promotion, Brochure designing are the plus points of a web designing and development company.

10. Always ask for post maintenance charges of the website from your web designing company.

11. Free online and customer care support should be provided by your web design and development company.

About the Author

I have more than 10 years of experience in IT industry. Linkedin Profile

I am currently messing up with neural networks in deep learning. I am learning Python, TensorFlow and Keras.

Author: I am an author of a book on deep learning.

Quiz: I run an online quiz on machine learning and deep learning.