Assigning Hex number

25 views
Skip to first unread message

suetibu

unread,
Feb 8, 2012, 4:24:35 PM2/8/12
to E-Prime
Hello,

I currently have script set up as follows:

xyz.OnsetSignalEnabled= True
xyz.OnsetSignalPort= &H4000
xyz.OnsetSignalData= 25

This works.

However, since the OnsetSignalPort is declared several times in the
script, is there a way to declare it as a global variable once in the
beginning of the script?

Does this work?
DIM PtAdd as Integer
PtAdd = CInt(&H4000)
xyz.OnsetSignalEnabled= True
xyz.OnsetSignalPort= PtAdd
xyz.OnsetSignalData= 25

This compiles fine but I'm not sure if it is the same.

Thanks,
S

Paul Groot

unread,
Feb 11, 2012, 7:44:31 PM2/11/12
to e-p...@googlegroups.com
Hi S,

If the address is static throughout the experiment, you could simply
declare a constant in the global user section:

Const MYPORT% = &H4000

You can then use MYPORT anywhere in your inline scripts.


xyz.OnsetSignalEnabled= True
xyz.OnsetSignalPort= MYPORT
xyz.OnsetSignalData= 25

The conversion to CInt is never required since the hex-value is
already interpreted as integer value.

cheers
Paul

David McFarlane

unread,
Feb 24, 2012, 1:13:53 PM2/24/12
to e-p...@googlegroups.com
Just a bit of clarification for those who don't go back to the days
of BASIC on Apple II and Commodore 64: The "%" in

Const MYPORT% = &H4000

is a type-declaration character that declares the constant MYPORT as
type Integer. In newer dialects you can achieve the same effect with

Const MYPORT as Integer = &H4000

depending on your own programming style.

-- David McFarlane

Reply all
Reply to author
Forward
0 new messages