# Digital codes

**URL:** <https://mworks.discourse.group/t/digital-codes/126>\
**Category:** Support\
**Created:** [June 17, 2021, 8:37pm UTC](https://mworks.discourse.group/t/digital-codes/126 "2021-06-17T20:37:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [June 17, 2021, 8:37pm UTC](https://mworks.discourse.group/t/digital-codes/126/1 "2021-06-17T20:37:07Z")

</div>

Hi Chris -

I have another question for you regarding format/syntax of %include files.

I’m trying to generate an ecodes.mwel that contains all the digital event codes for different trial events that we can then use in any experiment using %include.

The way I was thinking about it, this ecodes.mwel (attached) would have the values for different codes that would become accessible to my example1.mwel after using %include. And then, we can use the vpixx functionality you wrote to send the"event codes" followed by the “value codes” to the vpixx monitor. For example:

vpixx\_send\_blackrock\_sync\_word (e\_fixation\_width) //EVENT CODE:  
vpixx\_send\_blackrock\_sync\_word (v\_fixation\_width) //VALUE CODE

This doesn’t work - and when I %include ecodes, I get errors related to unknown variables, as follows:

00:00:04: ERROR: Unknown variable: e\_fixation\_width

3 questions please:

(1) Could you please guide me on how to define all the variables in the ecodes.mwel correctly to eliminate this error? Do I simply have to set all the event codes to zero at the beginning of ecodes.mwel? For example:

var e\_fixation\_width = 0

(2) How do we define variables without having them show up in the variables window when running MWorks?

(3) Am I right that we could use the vpixx\_send\_blackrock\_sync\_word to send event codes and value codes? For example:

vpixx\_send\_blackrock\_sync\_word (5001) //sending event code for fixation width  
vpixx\_send\_blackrock\_sync\_word (2010) //sending value for fixation window of 10 (ie. 10+2000 offset so that we don’t have negative codes)

Thank you!  
Yasmine

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [June 17, 2021, 8:37pm UTC](https://mworks.discourse.group/t/digital-codes/126/2 "2021-06-17T20:37:07Z")

</div>

Attachment: [ecodes.mwel.zip](https://mworks.discourse.group/uploads/short-url/xpFGSloddEc4akuexIRfZ6FWPlS.zip) (1.52 KB)

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [June 17, 2021, 8:50pm UTC](https://mworks.discourse.group/t/digital-codes/126/3 "2021-06-17T20:50:05Z")

</div>

Hi Yasmine,

> (1) Could you please guide me on how to define all the variables in the ecodes.mwel correctly to eliminate this error?

You’re just missing the “var” at the beginning of each declaration. That is, replace

```
e_fixation_width = 5001

```

with

```
var e_fixation_width = 5001

```

But that said:

> (2) How do we define variables without having them show up in the variables window when running MWorks?

It seems like it would be more appropriate to define these constants with [expression macros](https://mworks.github.io/documentation/latest/mwel/index.html#expression), rather than as variables. For example:

```
%define e_fixation_width = 5001

```

You can use the names of expression macros like variables and still write stuff like

```
vpixx_send_blackrock_sync_word (e_fixation_width) 

```

However, they aren’t variables, so they won’t show up in the variables window, and their values can’t be changed.

If, for some reason, you really do want to define them as variables, it isn’t possible to exclude them from the variables window. However, you can create one or more [groups](https://mworks.github.io/documentation/latest/components/folder.html) (aka folders) for the variables that you _do_ want in the variables window, and then expand just those groups. For example:

```auto
group 'Useful Variables' {
    var x = 1
    var y = 2
}

// Not useful variables
var z = 3

```

> (3) Am I right that we could use the vpixx\_send\_blackrock\_sync\_word to send event codes and value codes?

Yes, as long as all the codes are integers between 0 and 65535.

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [June 17, 2021, 10:03pm UTC](https://mworks.discourse.group/t/digital-codes/126/4 "2021-06-17T22:03:59Z")

</div>

Perfect! Thanks Chris!  
Yasmine

---

<div class="post-metadata">

**Author:** ![cstawarz](https://yyz1.discourse-cdn.com/flex031/user_avatar/mworks.discourse.group/cstawarz/32/3_2.png) [@cstawarz](https://mworks.discourse.group/u/cstawarz)\
**Post date:** [July 19, 2022, 7:06pm UTC](https://mworks.discourse.group/t/digital-codes/126/5 "2022-07-19T19:06:36Z")

</div>


