Maple Professional
Maple Academic
Maple Student Edition
Maple Personal Edition
Maple Player
Maple Player for iPad
MapleSim Professional
MapleSim Academic
Maple T.A. - Testing & Assessment
Maple T.A. MAA Placement Test Suite
Möbius - Online Courseware
Machine Design / Industrial Automation
Aerospace
Vehicle Engineering
Robotics
Power Industries
System Simulation and Analysis
Model development for HIL
Plant Modeling for Control Design
Robotics/Motion Control/Mechatronics
Other Application Areas
Mathematics Education
Engineering Education
High Schools & Two-Year Colleges
Testing & Assessment
Students
Financial Modeling
Operations Research
High Performance Computing
Physics
Live Webinars
Recorded Webinars
Upcoming Events
MaplePrimes
Maplesoft Blog
Maplesoft Membership
Maple Ambassador Program
MapleCloud
Technical Whitepapers
E-Mail Newsletters
Maple Books
Math Matters
Application Center
MapleSim Model Gallery
User Case Studies
Exploring Engineering Fundamentals
Teaching Concepts with Maple
Maplesoft Welcome Center
Teacher Resource Center
Student Help Center
Printer:-SetLanguageAttribute - add language attribute to Printer module
Printer:-ApplyLanguageAttribute - apply language attribute to remaining arguments
Printer:-GetLanguageAttribute - get language attribute from Printer module
Calling Sequence
Printer:-SetLanguageAttribute(expr, ...)
Printer:-GetLanguageAttribute(str)
Printer:-ApplyLanguageAttribute(str)
Parameters
Printer
-
Printer module
expr
string (str) or equation of the form (str = val)
str
string; name of language attribute
val
algebraic, string, or procedure; value of language attribute
Description
The SetLanguageAttribute command sets and clears language attributes. Multiple arguments are processed sequentially. If an argument has the form str=val, then the language attribute str is assigned the value val. If the language attribute str already has a value, it is overwritten. If an argument has the form str, then the language attribute str is cleared.
The GetLanguageAttribute command retrieves the current value of the language attribute str.
The ApplyLanguageAttribute behaves similarly to GetLanguageAttribute: if the value of language attribute str is of type algebraic or boolean, it is returned. However, if the value of language attribute str is of type procedure, it is applied to any remaining arguments of ApplyLanguageAttribute, and the result is returned.
For more information about language attributes and their function within CodeGeneration language definitions, see Language Attributes.
Examples
Change the string delimiter character to a single quote (') and define an equivalent for the Maple print command.
cg := echo('hello');
Use language attributes to specify templates for printing procedures and if/then/else structures in a target language.
LanguageDefinition[Define]("IfSampleLanguage", extend="default", SetLanguageAttribute( "Procedure_Begin" = proc(rettype, params) (Printer:-Indent(), rettype, " ", Printer:-GetScopeName()," ", params, Printer:-Endline()) end proc, "Procedure_ParametersInBody" = false, "Procedure_End" = "", "ParameterSequence_Begin" = "(", "ParameterSequence_Delimiter" = ",", "ParameterSequence_End" = ")", "If_Begin" = proc(x) (Printer:-Indent(), "if (",x,")", Printer:-Endline()) end proc, "If_Elsif" = proc(x) (Printer:-Indent(), "else if (",x,")", Printer:-Endline()) end proc, "If_Else" = proc() (Printer:-Indent(), "else", Printer:-Endline()) end proc, "If_End" = "" ) ):
my_signum := proc(x) if x>0 then 1 elif x = 0 then 0 else -1 end if: end proc:
integer my_signum (integer x) if (0 < x) Return(1); else if (x = 0) Return(0); else Return(-1);
See Also
Define, Language Attributes, Printer
Download Help Document
Copyright © MathResources Inc. All Rights Reserved.
www.mathresources.com