Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is AML? What is a program? What is AML? An AML can: –Automate frequently performed actions –Provide a quick and consistent way to set environments.

Similar presentations


Presentation on theme: "What is AML? What is a program? What is AML? An AML can: –Automate frequently performed actions –Provide a quick and consistent way to set environments."— Presentation transcript:

1

2 What is AML? What is a program? What is AML? An AML can: –Automate frequently performed actions –Provide a quick and consistent way to set environments –Decide what to do –Do things over and over

3 An AML can: (.cont) –Interact with users using text or menus –Run other AMLs and programs Running an AML Useful tips - &echo and &pause Watch files –Recording your session with a watch file –Converting a watch file to an AML

4 What is a program? Begin End Set mapextent Shade polygons Draw legend A series of instructions

5 Advantages of programming Reduces typing errors Maintains consistency Documents your work Automates repetitive tasks Offers new users a way to be more productive

6 AML programs can branch AML programs can respond with an appropriate action by branching Begin End Set mapextent Shade polygons Draw legend End Build Topology And Shade polygons Yes No Does the coverage have polygon topology?

7 AML programs can loop An AML program can repeat procedures Begin Draw coverage End Do you want to draw a coverage? No Yes Do you want to draw another coverage? No Yes

8 AML programs can communicate with users By selecting from menus By typing from a keyboard Picture a keyboard

9 AML programs can communicate with other programs AML programs can run other programs (modules) Begin Get a coverage End Check topology Draw coverage Menu to get a coverage Program to check topology Program to draw a coverage

10 AML programs should be clear and reliable Document AML programs Test AML programs Handle errors gracefully

11 Designing an application Determine functionally –User needs assessment System design strategies –Data flow diagram

12 Flow charts Map out the logic of a program Use different symbols for different actions Begin or end Get a coverage Menu to get a coverage Decision Flow Action Separate module

13 Pseudocode Represents the flowchart in a common language No code words should be used in the pseudocode Sample pseudocode: Get a coverage name from the user If the coverage has both polygon and line topology then Allow the user to choose either polygon or line topology If the coverage has only line topology then Allow the user to choose only line topology If the coverage has only point topology then Allow the user to choose only point topology Establish where on the screen the coverage will be displayed Display the coverage on the screen

14 The Header Name Purpose Arguments Global Variables Local Variables CoveragesDetailed Remarks Other Amls, Menus History

15 Major components of AML Directives are AML “commands” –Begin with an & Variables store a value –Surrounded by % % Functions return a value –Surrounded by [ ]

16 AML directives The first character is always an ampersand (&) –Example: &watch, &run, &popup AML directives work anywhere –(e.g., ARC, ARCPLOT, ARCEDIT) ARC: &run test.aml Arcplot: &popup test.aml Arcedit: &watch edit.wat

17 Directives

18 Variables: %cov% Store a value Set variables with the &setvar directive –Arc: &setvar cover = soil Use percent signs (%) to evaluate a variable –Arc: DESCRIBE %cover% –is the same as: –Arc: DESCRIBE soil Variable names are not case sensitive –Arc: DESCRIBE %cover% –is the same as: –Arc: DESCRIBE %COVER%

19 Local, global, and program variables Local variables –No dot (.) at beginning of name –Only available to the current AML program Global variables –Starts with a dot (.) –Available to all AML programs Program variables –Start with a colon (:) –Available to all AML programs Examples: :PROGRAM is automatically set to the current program &s cov = street ARCS %cov% &return Draw.aml &s.cov = street &r reset ARCS %.cov% &return Redraw.aml Arc: &lp program: :PROGRAM ARC

20 Functions Returns values Enclosed within square brackets [ ] This function:…tells the AML processor to and returns: [GETCOVER]Displays a menu of coverages /tom/street [RESPONSE] Ask the user to type some text Enter text AML Example:buildpoly.aml BUILD [response ‘Enter the coverage to build’] poly

21 End part 1

22 How to ask a question of a user with function statements [RESPONSE] Prompts the user to enter a response (accepts any text) Text that the user types becomes the return value of the function Arc: &s answer = [RESPONSE ‘Type ARC or POLY’] Type: ARC or POLY: POINT Arc: &type The user typed %answer% The user typed POINT [QUERY] Accepts only a yes or no answer from the user Returned value is.TRUE or.FALSE. Arc: &s continue = [QUERY ‘Do you want to kill the coverage’.FALSE.] Do you want to kill the coverage? YES Arc: &type %continue%.TRUE

23 Branching Obtaining information about a coverage &IF statements - &IF &THEN Logical expressions Indention

24 Getting information about a coverage ARC command: DESCRIBE –Displays characteristics on the screen –Sets AML reserved variables for the AML directive: &DESCRIBE –Only sets the AML reserved variables for the –Can be executed from any Arc/Info environment –Coverage examples: THIS VARIABLECONTAINS THIS VALUE DSC$ARCS Number of arcs DSC$POINTS Number of points DSC$POLYGONS Number of polygons DSC$TOPOLOGY.TRUE. If polygon topology is present.FALSE. If not DSC$QEDIT.TRUE. If coverage has been edited.FALSE. If not Handouts p4-5

25 Blocks of statements &DO &END –Every &DO must have an &END –Groups related code into a single block –Can be substituted for the single statement of &IF &THEN –Example: &IF [NULL %cov%] &then &do &sv cov = [GETCOV] &type Cover is %cov% &end ARCS %cov% A block

26 Decision making example Describe the coverage End Draw them red Yes No Does the coverage have arcs? &describe %cov% &if %des$arcs% > 0 &then &do LINECOLOR RED ARCS %cov% &end &END

27 &ELSE Describe the coverage Draw them red Yes No Does the coverage have arcs? Error message &describe %cov% &if %dsc$arcs% > 0 &then &do LINECOLOR RED ARCS %cov% &end &else &do &type ERROR - NO ARCS &end

28 &ELSE &IF Describe the coverage Draw them red Yes No ARCS > 0? Draw points green &describe %cov% &if %dsc$arcs% > 0 &then &do LINECOLOR RED ARCS %cov% &end &else &do &type ERROR - NO ARCS &end &else &if %dsc$points > 0 &then &do MARKERCOLOR GREEN POINTS %COV% &end &else &do &type ERROR - NO POINTS &end &END Points > 0? Yes Error message No Error message

29 Looping Nesting loops Making a decision at the beginning of a loop Making a decision at the end of a loop &do &to &by &do &list &do &repeat &do &until &do &while

30 Controlling the number of loops Four basic ways Count up to a set number&do&to&by Loop once for each element in list&do &list Make a logical decision at the beginning of the loop&do &while Make a logical decision at the end of the loop&do &until

31 Counting &do loops AML codingResults &do i - 1 &to 5 I = 1 &type i = %i% I = 2 &end I = 3 I = 4 I = 5 The default auto increment is one

32 Nesting &do loop AML coding &do outside = 1 &to 3 &do inside = 100 &to 400 &by 100 &type outside = %outside% inside = %inside% &end /* inside do loop &end /* outside do loop Results: outside = 1 inside = 100 outside = 1 inside = 200 outside = 1 inside = 300 outside = 1 inside = 400 outside = 2 inside = 100 outside = 2 inside = 200 outside = 2 inside = 300 outside = 2 inside = 400 outside = 3 inside = 100 outside = 3 inside = 200 outside = 3 inside = 300 outside = 3 inside = 400

33 Making a decision at the beginning of a loop Use &DO &UNTIL &s color = 1 &do &until not [QUERY ‘DRAW ANOTHER COVERAGE’] LINECOLOR %color% ARCS [GETCOVER] &s color = %color% + 1 &end /* DO Will always execute at least once The first coverage is drawn before the user sees the question asking to draw another coverage The loop terminates when the condition is.TRUE.

34 Write an AML program that accepts user input: Use your text editor to write a simple startup AML program (Start.aml) 1) Have your AML program get a coverage and copy it to a new coverage as the coverage name version 2. 2) Have the AML program open ArcPlot and select an arc coverage, and draw the coverage to the screen in red. 3) Add to your AML the ability to select a coverage and decide if it has arcs and draw it in red, or if no arcs display an error message 4) Add to your AML the ability to keep asking to draw more coverages. Do these one at a time Make sure each one works before you go to the next one!

35 Changing formats on an image Begin Get an image Decision Ask for name of a grid Convert to a grid Convert an image Kill the grid end &do &while [Query 'Do you want to convert an~ image:'.false] &s image = [getimage # -tiff 'Select an image to convert:'] &s grid = [response 'Enter the grid name'] IMAGEGRID %image% %grid% GRIDIMAGE %grid% GRAY %grid% TIFF KILL %grid% ALL &type 'You just created an image named' %grid%'.tif' &end Yes No

36 End


Download ppt "What is AML? What is a program? What is AML? An AML can: –Automate frequently performed actions –Provide a quick and consistent way to set environments."

Similar presentations


Ads by Google