Using object properties:
command <buy #@object#> { ' put's object's REAL name into #object#
if ( #(object):cost# < %money% ) then {
give <#object#>
set numeric <money; %money% - #(object):cost# >
}
else msg <Not enough money>
}
If the above doesn't work, try replacing the if with:
set numeric <cost; $objectproperty(#object#;cost)$>
if ( %cost% < %money% ) then {
I was making a shop IIRC, and it's what I used... kinda.
Oh, if you wish to clone an object, make sure you don't have a specific name to make it, use a numeric variable to *count* it (ie. clone <object; object%number%> )... You can also clone it directly into the inventory (clone<obj;obj%num%;inventory> IIRC).
I may write a little addition to my general ASL library... I will find it useful too.
A clone function, that returns the name of the clone it created - but also creates an array of names, so if you keep on cloning an object - then want to (say) remove ALL of these objects from the player - all you do is cycle through the array... Nice!
... I will take lots of time off work tomorrow, worked an extra 2 hours and should actually have been off this week, so my boss owes me

.