Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Wednesday, July 25, 2012

Industry-Standard Programming For Beginners: Lesson 4 (A Simple Program III)

Having to change the program whenever a different time is to be entered is tedious, and there is a much better way to organise things - by making timetaken a variable, and by supplying a value for it as data. In this way, the program can remain the same, and won't need to be recompiled each time. The data is completely distinct from the program, and depending on the compiler you are using, may be entered either via the keyboard or a data file. Whichever you choose, the data can be input into the program using the read statement. This principal is illustrated in the example program below, in which two values are read in as data:

Program SimpleInterest ( input, output );

{********************************************************************

Example Program 2

Calculation of simple interest on a principal at a given of interest

and over a given number of days.

*******************************************************************}

const

rate = 10; { percent }

year = 365; { days }

var

principal, interest, amount: real;

time: integer;

begin

read ( principal, time );

interest:= time / year * rate / 100 * principal

amount:= principal + interest

writeln ( 'Example Program 2: Computation of simple interest' );

writeln ( '=================================================' );

writeln;

writeln ( 'principal = $', principal:7:2 );

writeln ( 'interest rate = ', rate:4, ' %' );

writeln ( 'term = ', time:4, ' days' );

writeln;

writeln ( 'interest = $', interest:7:2 );

writeln ( 'new value of principal = $', amount:7:2 );

end.

Before we look at the purpose of the program, try comparing its general format with that of Example Program 1. Again, there is an initial comment; but this time, in addition, there are further comments interspersed with the code. Comments may appear anywhere, except in a quoted piece of text, or in the middle of a multi-character symbol (multi-character symbols include names, numbers and the assignment operated ':='). Apart from the comments, the general structure is the same as that of Example Program 1. There is a program heading, followed by a series of declarations, i.e. lists of constant variable names to be used. (Comparing a computer program with a recipe, the declarations can be likened to a list of ingredients preceding the instructions.) Then comes a set of statements to be executed, enclosed between the words begin and end - the statement part. All Pascal programs have these three parts: heading, declarations, and statement part, and all are terminated by '.'. The section of the program consisting of the declarations and statement part is known as the program body, or block.

Certain words occur in both Example Program 1 and 2. These include program, var, begin and end, which always have a special meaning in Pascal. These are known as reserved words. In this program, they have been highlighted by bold lettering, and if you are lucky, your compiler will format your code in the same way for you, automatically.

The title and names used to identify quantities within a program are invented by the programmer. Any suitable names may be chosen, with the exception of reserved words. Formally, a name (or 'identifier') in a program may consist of any sequence of letters or digits, as long as it begins with a letter.

The purpose of Example Program 2 is to calculate the interest paid on a sum of money over a given number of days, with a given rate of interest.

Now that we're aware of how the two programs are similar, and we have a better understanding of how a program should be constructed, we will move on to how Example Program 2 is so different (and so much more powerful) than Example Program 1, in the next lesson.

-Jonathan

This is a guest article, brought to you by http://www.gorard.co.uk/.


View the original article here

Wednesday, July 18, 2012

Learn Computer Programming and Make Your Job Easier

If you have a job where you sit behind a computer a good bit of the time, you could probably make your life a whole lot easier if you would learn computer programming. I'm not saying you have to turn into some kind of computer genius, of course, but if you were to learn how to write a few little programs that would do some of the more mundane tasks for you with just the click of a button, you could free up loads of time for other stuff.

See if this sounds familiar; I have a friend that works in purchasing at a pretty successful company. Every day he has to take a spreadsheet from the previous day and compare it to another spreadsheet for the current day to determine what ordered parts have come in. He got pretty industrious and even got two computer monitors set up on his desk so that he could look at both of them and compare them side by side. But that's where the technology ends. He then takes a notepad and a pen and starts scanning the worksheet and writing stuff down. It usually takes him about 2 hours to do this. Everyday! Imagine how many mistakes he must make! Especially when you are writing down complex part numbers and quantities, and then people keep coming in and interrupting to ask a question. I can't imagine my first two hours of everyday being that mind numbing and stressful.

What my buddy does not understand is, the spreadsheet program his company uses is the most widely used program out there. In fact, the company that makes his spreadsheet program also makes the email software he uses, the database software that they use to track the warehouse inventory, and even the word processing program they use for correspondence! Heck, they even make the software that they use to do presentations to customers! I'm not going to name this software company, but unless you have been living in a soft little micro cave for last 30 years, I'm pretty sure you can figure it out. Well, this software company did a pretty handy little thing when they built their package of software to sell to the masses. They incorporated a handy little tool with it that allows any every day Joe or Joann to write programs to manipulate their software in even more ways than what they released. Shoot, they made it so versatile that you can write a program in it to do just about anything on your computer and the only way you would know it was a spreadsheet (or email, or database, etc.) program is by the icon you have to click to get it running. That is cool.

But not only is it cool, it is powerful! If my buddy were to spend a little time learning and familiarizing himself with this tool, he could easily (and I do mean easily), write a program that he could use so that when he gets to work, he could open a blank spreadsheet, click a button, and literally seconds later have today's spreadsheet compare itself with yesterday's spreadsheet and list out a detailed report on what had been received. There is two whole hours out of his day that he just reclaimed! His boss has no idea what he has done, so what can he do with that quarter of a workday he just gained back? Maybe write another program to make some other aspect of his job easier? Or add-on to his existing program so that it automatically emails the report to his boss? Remember, the same software company made the email program so it all works together by design.

If learning computer programming is something that you would like to do but think that it is too hard, or that you just wouldn't be able to understand it, then let me tell you a secret. I taught myself how to write a whole bunch of programs and the number one tool I used was the internet. That's right. I would just plunk in my query in a reputable search engine and I would get all kinds of explanations and answers. The problem is knowing what questions to ask and how to ask them. And for that you need a little bit of basic programming knowledge. I might can help you get that knowledge by introducing you to some basic programming techniques. You never know, you might just decide to completely change careers!


View the original article here

Saturday, July 14, 2012

SAP Business One Customizations and Integrations Programming With SDK Libraries

SAP B1 is friendly to Microsoft Visual Studio programmers via its so-called Software Development Kit. In the next version 9.0 expected in the fourth quarter of 2012 it is rebranded as 'Business One Studio'. Let's make short technical introduction and then try to talk about cases studies and get popular questions answered. Let's begin with SDK categorization:

1. UI API. 'The UI API provides programmatic access to windows, menus, and events in SAP Business One. The UI API allows you to create new windows, modify existing windows, add new business logic, add or modify application menus, and more.' After introduction from 'Help Center' we would like to mention that user interface modification might be vulnerable to such future projects as upgrades. We would rather recommend you to concentrate on integration type of projects and see next paragraph

2. DI API. 'The DI API provides a programmatic interface to SAP Business One through a set of fully functional business objects. The DI API provides access to the business logic and data-access layers of SAP Business One.' It is much easier to review integration code and recompile it with new release DLL set

3. DI Server. 'The DI Server is an extension of the DI API and supports all its objects. It is intended for high-volume data integration, where numerous client connections must be managed simultaneously and optimized for speed. It is also suitable where Web-services architecture is preferred.' Here you should think about maximum performance

4. Code samples are available in C# and VB. This is one of the reasons for you to consider coding in these languages. However if you are comfortable to translate to your favorite.Net compliant language feel free to deploy it

5. Table structure. Here you have to combine client interface and SDK. Login B1 and in menu View->System Information mark it. Open the form where you need to know the table and place cursor over and read field and table name on the bottom left corner. Write down table name and in Help Center search it. Try the following exercise. Open Sales Order form and place cursor over Customer field. And you should see the field Name CardCode and table ORDR. Then review this table in Help Center Search. If you are comfortable to find the table on your own directly in Kit then go to Customization Tools -> Database Table Reference

6. Integrations. It is recommended first to create user defined tables in client application and then use them as staging objects. You can import records to such table directly via SQL insert statement as it doesn't participate in core business logic. Next step is DI API programming in Visual Studio where you read records from staging table and create AR Invoices, Purchase Orders, etc.

7. Integration with Linux and PHP. This is frequent request due to the fact that custom ecommerce portal are often hosted in MySQL on Linux platform. Good recommendation is to consider SOAP XML Web Service with SDK libraries. Web service is computer platform neutral and could be called from Linux

Andrew Karasev is SAP BO consultant and Great Plains Certified Master, MVP, help@efaru.com 1-866-304-3265, 1-269-605-4904. He is also the initiator of eFaru project http://www.efaru.com/ and founder of Alba Spectrum information space


View the original article here