Nov 13, 2013; 23:18
Tami Williams
lasso 9 custom types optional parameters + multiple onCreate methods
I'm expanding my commented examples for myself to help this stuff stick. Thanks in advance for all the help :)
So it seems like there's no way to allow a user to create an object using both:
var('partyA' = party('', 0, 'Nokia', '123 Main Street', 'Atlanta', 'GA', '30341', 'active'))
and
var('partyA' = party(-active_status='activeX', -name= 'Nokia', -address='123 Main Street', -city='Atlanta', -state='GA', -zip='30341'))
by having the onCreate methods in my type below; it seems like I can only do 1 way or the other, not both.
Is that correct?
[
// define the CLASS (named "party")
define party => type {
// define Properties (aka local variables)
// data = define variables inside the type
// public = can be used outside the type and can be output on the page
// private = can only be called from methods defined within the owning type; can only be used inside the type and can NOT be output on the page
// protected = can be called from within the owning type or any type that inherits from that type; can NOT be output on the page
// ::string means assigned values must be text strings
// = '' means that if no default value is assigned, use '' (empty string) as the default value
data
protected tablename::string = 'party', // default tablename is party
public name::string = '',
public address::string = '',
public city::string = '',
public state::string = '',
public zip::string = '',
public active_status::string = '',
private id::integer = 0 // default ID is 0
// make status an alias for active_status)
public status() => { return .active_status }
// define METHODS
// _default_ onCreate method, with no data members, is added here to allow you to create the object WITHOUT REQUIRING default values; only need to add this default onCreate method IF any other onCreate methods exist
// means can create object like this:
// var('myParty' = party())
public onCreate() => {}
// define other public onCreate methods ONLY if you want to REQUIRE default values for each of the local variables when the object is created
// .'name' = #name means set the local variable value to the assigned default value if it exists
// add this onCreate method so can create object like this:
// var('partyA' = party('', 0, 'Nokia', '123 Main Street', 'Atlanta', 'GA', '30341', 'active'))
public onCreate(
tablename::string = 'party', // default tablename is PARTY
id::integer = 0, // default ID is 0
name::string = '',
address::string = '',
city::string = '',
state::string = '',
zip::string = '',
status::string = '') => {
.'tablename' = #tablename
.'id' = #id
.'name' = #name
.'address' = #address
.'city' = #city
.'state' = #state
.'zip' = #zip
.'active_status' = #status // use local variable name 'status' to access active_status
}
// ... = local variable called 'rest'
// this onCreate means can create object like this:
// var('partyA' = party(-active_status='activeX', -name= 'Nokia', -address='123 Main Street', -city='Atlanta', -state='GA', -zip='30341'))
public onCreate(...) => {
with i in #rest do => {
match(#i->name) => {
case('name')
.name = #i->value
case('address')
.address = #i->value
case('city')
.city = #i->value
case('state')
.state = #i->value
case('zip')
.zip = #i->value
case('active_status')
.active_status = #i->value
}
}
}
}
]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"It's better to burn out than to fade away."
Tami Williams
Creative Computing
Let us help you make frustrating, costly, and inefficient processes more efficient, less costly and scalable.
Lasso, MySQL and FileMaker specialists.
Tel/Fax: 770.457.3221
E-Mail: info@asktami.com
Web: http://www.asktami.com/
LinkedIn: http://www.linkedin.com/in/asktami
Twitter: http://twitter.com/asktami
iChat/AIM/Skype: tamiwilliamsusa
FileMaker Solutions Alliance Associate | Lasso Professional Alliance Member | Certified Lasso Developer | FileMaker 11 & 12 Certified Developer
------
If you want to receive sporadic email from Creative Computing regarding news at the company and announcements about upcoming Lasso webinars and online classes, please opt-in at http://tinyurl.com/yj7eqlg
#############################################################
This message is sent to you because you are subscribed to
the mailing list Lasso
Lasso@lists.lassosoft.com
To unsubscribe, E-mail to: <Lasso-unsubscribe@lists.lassosoft.com>
Send administrative queries to <Lasso-request@lists.lassosoft.com>
Nov 14, 2013; 05:56
jolle
Re: lasso 9 custom types optional parameters + multiple onCreate methods
Nov 14, 2013; 23:02
Tami Williams
Re: lasso 9 custom types optional parameters + multiple onCreate methods
Nov 15, 2013; 07:52
jolle
Re: lasso 9 custom types optional parameters + multiple onCreate methods
Nov 15, 2013; 13:14
Kyle Jessup
Re: lasso 9 custom types optional parameters + multiple onCreate methods
Nov 16, 2013; 00:05
Tami Williams
Re: lasso 9 custom types optional parameters + multiple onCreate methods