Programming Cheng-Ling Kuo

Slides:



Advertisements
Similar presentations
IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Angela Des Jardins.
CS311 – Today's class Perl – Practical Extraction Report Language. Assignment 2 discussion Lecture 071CS Operating Systems I.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Scalar Variables Start the file with: #! /usr/bin/perl –w No spaces or newlines before the the #! “#!” is sometimes called a “shebang”. It is a signal.
10 November JavaScript. Presentation Hints What do YOU think makes a good presentation Some of my suggestions Don’t write full sentences on slides Talk,
Operators. Perl has MANY operators. –Covered in Chapter 3 of Prog.Perl Most operators have numeric and string version –remember Perl will convert variable.
Fundamental Programming Structures in Java: Comments, Data Types, Variables, Assignments, Operators.
CS241 PASCAL I - Control Structures1 PASCAL I - Control Structures Philip Fees CS241.
JavaScript, Third Edition
Admin Office hours 2:45-3:15 today due to department meeting if you change addresses during the semester, please unsubscribe the old one from the.
Introduction To C++ Programming 1.0 Basic C++ Program Structure 2.0 Program Control 3.0 Array And Structures 4.0 Function 5.0 Pointer 6.0 Secure Programming.
Bash Shell Scripting 10 Second Guide Common environment variables PATH - Sets the search path for any executable command. Similar to the PATH variable.
Ruby (on Rails) CSE 190M, Spring 2009 Week 1. The Players Kelly "Everyday I'm Hustlin' " Dunn Kim "Mouse" Todd Ryan "Papa T" Tucker.
PHP Overview CS PHP PHP = PHP: Hypertext Preprocessor Server-side scripting language that may be embedded into HTML One goal is to get PHP files.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
4. Python - Basic Operators
Introduction to Python Lecture 1. CS 484 – Artificial Intelligence2 Big Picture Language Features Python is interpreted Not compiled Object-oriented language.
Introduction to Python Basics of the Language. Install Python Find the most recent distribution for your computer at:
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 2 Input, Processing, and Output.
PYTHON. Python is a high-level, interpreted, interactive and object- oriented scripting language. Python was designed to be highly readable which uses.
2440: 211 Interactive Web Programming Expressions & Operators.
Language Elements 1. Data Types 2 Floating Point (real) Single Precision Double Precision Decimal Fixed Point (integer) Byte Short Integer Long Numerical.
Lecture 4 PL/SQL language. PL/SQL – procedural SQL Allows combining procedural and SQL code PL/SQL code is compiled, including SQL commands PL/SQL code.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
Chapter 3: Data Types and Operators JavaScript - Introductory.
TUTORIAL 10: PROGRAMMING WITH JAVASCRIPT Session 2: What is JavaScript?
Perl By Gabe and Ted. History Perl was created by Larry Wall while working at NASA’s Jet Propulsion Labs. Larry Wall also created patch which is in widespread.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
Ruby on Rails. What is Ruby? Programming Language Object-oriented Interpreted.
C STRUCTURES. A FIRST C PROGRAM  #include  void main ( void )  { float height, width, area, wood_length ;  scanf ( "%f", &height ) ;  scanf ( "%f",
VBScript Language. What is VBScript Based on the Visual Basic family of languages Supports object oriented features Interpreted Loosely Typed Implicitly.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
Smalltalk (and Squeak) Aida Dungan and Rick Shreve.
EIW - ASP Introduction1 Active Server Pages VBScript.
What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports.
C463 / B551 Artificial Intelligence Dana Vrajitoru Python.
JavaScript Syntax, how to use it in a HTML document
Python Functions.
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Maria Kazachenko
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Introduction to Visual Basic Programming. Introduction Simple Program: Printing a Line of Text Another Simple Program: Adding Integers Memory Concepts.
©Colin Jamison 2004 Shell scripting in Linux Colin Jamison.
Visual Basic Programming I 56:150 Information System Design.
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
CS241 PASCAL I - Control Structures1 PASCAL Control Structures Modified Slides of Philip Fees.
Introduction to Python Dr. José M. Reyes Álamo. 2 Three Rules of Programming Rule 1: Think before you program Rule 2: A program is a human-readable set.
Introduction to Perl. What is Perl Perl is an interpreted language. This means you run it through an interpreter, not a compiler. Similar to shell script.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
Visual Basic Review LBS 126. VB programming Project Form 1Form 2Form 3 Text boxButton Picture box Objects Text box Button Objects.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
PERL By C. Shing ITEC Dept Radford University. Objectives Understand the history Understand constants and variables Understand operators Understand control.
Chapter 6: Looping. Objectives Learn about the loop structure Create while loops Use shortcut arithmetic operators Create for loops Create do…while loops.
Chapter 2: Data and Expressions. Variable Declaration In Java when you declare a variable, you must also declare the type of information it will hold.
Operators. Perl has MANY operators. –Covered in Chapter 3 of Camel –perldoc perlop Many operators have numeric and string version –remember Perl will.
1 Agenda  Unit 7: Introduction to Programming Using JavaScript T. Jumana Abu Shmais – AOU - Riyadh.
Information and Computer Sciences University of Hawaii, Manoa
Definition of the Programming Language CPRL
Chapter 6 JavaScript: Introduction to Scripting
Introduction to Python
Statements, Comments & Simple Arithmetic
Control Structures: if Conditional
Use of Mathematics using Technology (Maltlab)
T. Jumana Abu Shmais – AOU - Riyadh
Presented by, Mr. Satish Pise
The Selection Structure
DATA TYPES AND OPERATIONS
REPETITION Why Repetition?
Presentation transcript:

Programming Cheng-Ling Kuo

Review - programming Interpreted and Interactive language, which is Similar to C or Fortran language Character: comment(;) delimiter(,) linking multi-lines(&) Avoid IF and use GT, >, or WHERE Use IDL ’ s function and procedure(TOTAL, WHERE) Use array operation rather than loops

Review- general operator Grouping of expressions Assignment Addition & string concatenation Subtraction & unary negation Multiplication Division Exponentiation Minimum of (Careful!) Maximum of (Careful!) Matrix multiplication Modulus (remainder) Array concatenation Conditional expression ( ) = + - * / ^ < > # MOD [ ] ?

Other Operators Relation operators: EQ, LE, LT, GT, GE Flase(0), True(1) Boolean operators

How to start a procedure PRO hello name = "" read, "input a name:", name print, "hello, ", name END Save(ctl-S), Compile and Start IDL> input a name: IDL> hello, johnny

Create your own command PRO hello, name ;name = "" ;read, "input a name:", name print, "hello, ", name END Use your command 1. Compile: or IDL>.compile hello 2. start IDL>hello, “ johnny ” hello, johnny

Executive command.compile IDL>.COMPILE "E:\code\IDL\test\hello.pro“ or IDL>.COMPILE hello retall As compiling error.

Batch, procedure, function x=[10,30,90] PRINT, x PLOT, END FUNCTION f x=[10,30,90] PRINT, x PLOT, x RETURN, x.compile f res = f() PRO P END x=[10,30,90] PRINT, x PLOT, x.compile p P

Procedure definition PRO procedure_name, param 1, param 2, keyword 1 =keyword 1, … statements END Statement is required: PRO, END Parameters are positional or keyword RETURN is optional Example PRO hello, name print, “hello, ”, name END

Procedure call PROCEDURE_NAME, p 1, p 2,..., p n Invoke a system or user written procedure Example user written function IDL>hello, “ Ted ” System procedure IDL>plot, [0, 1]

Function definition FUNCTION function_name, param 1, param 2, keyword 1 =keyword 1, … statements return, value_expression END Statement is required: FUNCTION, END Parameters are positional or keyword RETURN is required A function has no data type Example function myadd, a, b return, a+b END

Function Call var = FUNCTION_NAME(p 1, p 2, …) Invoke a system or user written function Example user written function IDL> v = myadd, 1, 2 IDL> print, v System function IDL> v = TOTAL([1,2,3]) IDL> print, v

Parameter: positional & keyword Positional Input by parameter position Copy in & out - Call by reference Keyword Input by keyword string Call by reference

Parameter: Call by reference Positional Input by parameter position Copy in & out - Call by reference PRO test, a, b=b a=-1 b=-1 END IDL>r=100 & s=100 IDL>test, r, b=s IDL>print, r, s (variable changed!)

Parameter passing By value Expression: a+0 Constants: Subscripted variables: m(10) Structure tag refercnce: s.tag By reference Regular variables: a, b, c

Checking parameters N_params(): return numbers of paramerters Keyword_set(): return true or false Size(): return type and size of parameters or variables

Common block COMMON Block_Name, Variable1, Variable2,..., Variablen Def: creates a common block with the designated name and places the variables whose names follow into that block. Example PRO ADD, A COMMON SHARE1, X, Y, Z, Q, R A = X + Y + Z + Q + R PRINT, X, Y, Z, Q, R, A RETURN END PRO SUB, T COMMON SHARE1, A, B, C, D T = A - B - C - D PRINT, A, B, C, D, T RETURN END

pro suba common share, a, b, c, d a=1 b=2 c=3 d=4 print, "the sum is ", a+b+c+d end Common block(Example) pro main suba subb subc end Common share A, B, C, D pro subb common share, p, q, r, s print, "p=", p print, "q=", q print, "r=", r print, "s=", s p=100 end pro subc common share, a, b, c, d print, "the sum is ", a+b+c+d end

“ String ” family String() Strlen() Strtrim() Strcompress() Strlowcase() Strupcase() Strpos() Strmid() Strput()