MetaCase Homepage
Forum Home Forum Home > > MetaEdit+
  New Posts New Posts RSS Feed - Mapping properties
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Mapping properties

 Post Reply Post Reply
Author
Message
Tinhinane View Drop Down
Member
Member


Joined: 16.Mar.2018
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote Tinhinane Quote  Post ReplyReply Direct Link To This Post Topic: Mapping properties
    Posted: 02.May.2018 at 20:32
Hello,

I am using MetaEdit+ to describe a small language for automation. What I want to do is to map my objects states with signal states; meaning say a Switch object with property 'state' (fixed list) [Pressed, Released], I want to map that with [1, 0]. Is there a way to add that on top of my language?
Back to Top
stevek View Drop Down
MetaCase
MetaCase
Avatar

Joined: 11.Mar.2008
Points: 641
Post Options Post Options   Thanks (0) Thanks(0)   Quote stevek Quote  Post ReplyReply Direct Link To This Post Posted: 02.May.2018 at 21:30
DSM is about raising the level of abstraction, so the default answer would be that the language should be human-readable - just Pressed/Released - and the generator should be responsible for mapping that to 1/0. 

With just two values, you can simply say "if :state='Pressed' then '1' else '0' endif". If there were more values, I often like to put the mapping as a translator rather than logic:
to '%stateValue
$Pressed $1
$Released $0'
endto

:state%stateValue
If some strings on the left-hand side of the translator are substrings of later strings, either re-order or switch to using more precise regular expressions like /^Pressed$/.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.05
Copyright ©2001-2022 Web Wiz Ltd.

This page was generated in 0.125 seconds.