1 / 36

What is AML?

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. An AML can: (.cont) Interact with users using text or menus Run other AMLs and programs

amity
Download Presentation

What is AML?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. 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

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

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

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

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

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

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

  9. AML programs should be clear and reliable • Document AML programs • Test AML programs • Handle errors gracefully

  10. Designing an application • Determine functionally • User needs assessment • System design strategies • Data flow diagram

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

  12. 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

  13. The Header Detailed Remarks Coverages Name Arguments Other Amls, Menus Purpose Global Variables Local Variables History

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

  15. 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

  16. Directives

  17. 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%

  18. Local, global, and program variables Draw.aml • 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 Redraw.aml &s .cov = street &r reset ARCS %.cov% &return Arc: &lp program: :PROGRAM ARC

  19. Returns values • Enclosed within square brackets [ ] Functions • 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

  20. End part 1

  21. 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

  22. Branching • Obtaining information about a coverage • &IF statements - &IF &THEN • Logical expressions • Indention

  23. Getting information about a coverage • ARC command: DESCRIBE <geo_dataset> • Displays <geo_dataset> characteristics on the screen • Sets AML reserved variables for the <geo_dataset> • AML directive: &DESCRIBE <geo_dataset> • Only sets the AML reserved variables for the <geo_dataset> • Can be executed from any Arc/Info environment • Coverage examples: • THIS VARIABLE CONTAINS 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

  24. 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

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

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

  27. &ELSE &IF &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 Describe the coverage Yes ARCS > 0? Draw them red No Error message Yes Draw points green Points > 0? No Error message

  28. 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

  29. 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

  30. Counting &do loops • AML coding Results • &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

  31. 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 Nesting &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

  32. 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.

  33. 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!

  34. Decision Changing formats on an image &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 Begin No end Yes Get an image Ask for name of a grid Convert to a grid Convert an image Kill the grid

  35. End

More Related