1 / 15

Parameters and Their Options

Parameters and Their Options. caller ( ); begin // str and acc are arguments passed to the called method obj.called( str, acc ); end ;. called (pString : String ; pAccount : Account ); // pString and pAccount are parameters of the called method.

vina
Download Presentation

Parameters and Their Options

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. Parameters and Their Options • caller ( ); • begin • // str and acc are arguments passed to the called method • obj.called( str, acc ); • end; • called (pString : String; pAccount : Account); • // pString and pAccount are parameters of the called method • Parameter option determines how a parameter may be changed • If a change is allowed, the change is reflected in the argument • called (pString : String constant | input | output | io ; • pAccount : Account constant | input | output | io ); 9.1

  2. constant • caller ( ); • begin • obj.called( str, acc ); • end; • called (pString : String constant; pAccount : Account constant); • begin • pString := 'Hello World'; // NOT allowed • pString.replaceChar('a', 'b'); // NOT allowed • pAccount := allAccounts.getAtKey('AN6374'); // NOT allowed • pAccount.balance := 0; // NOT allowed • pAccount.setBalance(0); // NOT allowed • end; • constant is the default option and need not be specified 9.2

  3. input • caller ( ); • begin • obj.called( str, acc ); • end; • called (pString : String input; pAccount : Account input); • begin • pString := 'Hello World'; // NOT allowed • pString.replaceChar('a', 'b'); // allowed • pAccount := allAccounts.getAtKey('AN6374'); // NOT allowed • pAccount.balance := 0; // allowed • pAccount.setBalance(0); // allowed • end; 9.3

  4. output • caller ( ); • begin • obj.called( str, acc ); • end; • called (pString : String output; pAccount : Account output); • begin • pString := 'Hello World'; // allowed • pString.replaceChar('a', 'b'); // allowed • pAccount := allAccounts.getAtKey('AN6374'); // allowed • pAccount.balance := 0; // allowed • pAccount.setBalance(0); // allowed • end; • output parameters are set to null at the start of the method 9.4

  5. io • caller ( ); • begin • obj.called( str, acc ); • end; • called (pString : String io; pAccount : Account io); • begin • pString := 'Hello World'; // allowed • pString.replaceChar('a', 'b'); // allowed • pAccount := allAccounts.getAtKey('AN6374'); // allowed • pAccount.balance := 0; // allowed • pAccount.setBalance(0); // allowed • end; 9.5

  6. RootSchema Examples • String primitive type • substring := longstring.scanUntil(delims, index); • // delims is constant • // index is io • Collection class • accountsByNumber.copy(accountsByName); • // accountsByName is input • Object class • getLockStatus(object, lockType, lockDuration, lockedBy); • // object is constant • // lockType, lockDuration, • lockedBy are output 9.6

  7. Method Options • abstract • updating • protected • mapping • clientExecution • serverExecution • called ( pString : String; pAccount : Account ) updating, protected, serverExecution; 9.7

  8. initTransaction (pMyAccount : Account; pMyBranch : Branch ) : String; vars str : String; begin if pMyAccount = nullthen str := 'A valid Account is required'; elseif pMyBranch = nullthen str := 'A Branch is required'; endif; return str; end; Return Value 9.8

  9. Constructors and Destructors • Constructor • method called ‘create’ • executed after create instruction • Destructor • method called ‘delete’ • executed before delete instruction • create ( ) updating; • begin • self.password := 'password'; • end; 9.9

  10. Mapping Methods • Same name as property • Reimplements default ‘get’ and ‘set’ behaviour • Defined signature • set parameter • true when property is updated • false when property is read name ( set : Boolean; _value : String io ) mapping; begin end; 9.10

  11. Primitive Methods 9.11

  12. External Methods • Same as JADE Method • name • parameters • options • Library • Entry Point • isValid( ): Booleanis"dateIsValid"in"jomsupp” ; 9.12

  13. External Functions • Library • Entry Point in signature • Invoked using the call instruction // Open your internet browser call _shellExecute (null, 'open', 'http://www.discoverjade.com', null, null, null); // Open your email program call _shellExecute (null, 'open', 'mailto:gdavies@jade.co.nz?subject=Hello World&body=The traditional greeting.', null, null, null); 9.13

  14. SequenceNumber number next() Bank myBankAcctSeqNum myCustomerSeqNum create() delete() nextBankAcctNum() nextCustomerNum() Challenge #18 In the BankingModelSchema • Add a SequenceNumber class • Add a SequenceNumber::number property • Code a SequenceNumber::next method thatincrements number and then returns that value In the Bank class • Add references to SequenceNumber calledmyCustomerSeqNum and myBankAcctSeqNum • Code a Bank constructor to create the references • Code a Bank destructor to delete the references • Code a Bank::nextBankAcctNumber method • Code a Bank::nextCustomerNumber method In the JadeScript class • Execute the createBank method 9.14

  15. sequence number newcustomer bankroot object Challenge #19 What’s thenext number? In the BankingModelSchema add contructors to Customer and BankAccount that assign the next available number to the object 9.15

More Related