¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Question on finding the number of defined array elements.


 

Hi All,

I am really sorry that my post sounded condescending. That wasn't
the intention, and I absolutely agree with the points that this is a
forum to ask questions, whatever the level. I truly hope I haven't
put anyone off asking for help in the future.

At the risk of digging an even bigger hole... what I was getting at
was: Crestron have done the right thing *not* to include pointers in
S+. S+ is (I think the majority would agree) only an extension to
Crestron's fundamental, symbolic, development language. As Matt
pointed (no pun intended!) out, there are truly great SIMPL Windows
programmers out there (and I don't count myself in there by any
stretch) who don't do, or care to do, much with S+. Given that S+
isn't therefore an essential core competency for Crestron
programming, the inclusion of pointers in the language would present
a dangerous temptation. This allows people to dabble in S+ without
too much risk of nuking an otherwise perfectly good system.

Note:
For those that don't agree that S+ is a non-core competency, please
don't write back. Life's too short. And my personal opinion is that
S+ is a very useful extension... just not core :-p

Ol

--- In Crestron@..., "Matt" <mjrtoo@...> wrote:

...I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in
procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors,
programmers
do" ;-)


Hey, I resemble that comment. ;)

But in all honesty, I think the majority of Crestron programmers
don't have procedural backgrounds, and don't really need to, it's
not
a procedural language, some people might even say that it's not
MEANT
to be programmed with S+.

A lot of the programmers here are the 'cream of the crop' and I for
one appreciate the help, but I also like to think I help as well.
Sure, not with pointers or 'dynamic memory assignment' or what-have-
you, and also make syntax errors that I ask about, but helping out
with a 'I can't figure out how the example checksum is calculated'
is
good too...right? ;)


Matt
 

Right on, I might add that trying to not put someone down while
helping is a plus!



Over the years, I have programmed in many different languages
starting with assembler and moving up into what are called 4GL and
true Object Oriented languages. They each have their strong points
and their weaknesses. Each have places where they are the better
language for the usage. C was designed to be a higher level language
than assembler but still allow some of the power of assembler with
its pointers.

For some, programming languages are more of a religious war (like
with OS's) where their language or way of programming is the best or
only way. For the good programmers, a language is just a tool where
they find the strengths and weaknesses and how to use it for the job
being done.

Simpl and S+ are just programming languages. We need to learn
their strengths and weaknesses just like any other tool. There are
some places where Simpl is the right tool and some where S+ is the
right one. Since Simpl is the "native" language of the Crestron
processors and is required for everything you do programming in the
Crestron environment, it is the one that most time should be spent
on. When you find places S+ is the better language, use it but also
understand where it should and should not be used.

I know that in this environment, I am not one of your 'cream of the
crop' programmers. I am still trying to learn this envirnoment. The
way this type of group works isif you can help, do so. Some of the
times when you try to help, you find you are wrong but most of the
times, you are not. Some of the times, you find that you may be
right but there is a better way.

Chris


-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On
Behalf Of Matt
Sent: Friday, January 23, 2009 5:10 PM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined
array elements.

...I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors, programmers
do" ;-)


Hey, I resemble that comment. ;)

But in all honesty, I think the majority of Crestron programmers
don't have procedural backgrounds, and don't really need to, it's
not
a procedural language, some people might even say that it's not
MEANT
to be programmed with S+.

A lot of the programmers here are the 'cream of the crop' and I for
one appreciate the help, but I also like to think I help as well.
Sure, not with pointers or 'dynamic memory assignment' or what-have-
you, and also make syntax errors that I ask about, but helping out
with a 'I can't figure out how the example checksum is calculated'
is
good too...right? ;)




------------------------------------




Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in
the Database area.

Yahoo! Groups Links


Chip Moody
 

Yeah. +1. I'd +2, but that would just be tacky of me.

Great post, Chris.

- Chip

--- In Crestron@..., "fellatedone" <j.legge@...> wrote:

Fantastic post. Thank you.

-JOHN

--- In Crestron@..., Chris Erskine <chris@> wrote:

Over the years, I have programmed in many different languages...


Jeremy Weatherford
 

An integer index is just as effective as a pointer into a string. The
other issue you bring up is that strings are not null-terminated.
Since we constantly work with serial protocols that use null bytes, I
happen to think this is a very good thing. If you want to pass
substrings around without recopying, just pass an index and a length,
and have the receiving routine only look at those characters.

Don't forget about byte() and setbyte() when you're lamenting the lack
of pointers -- they make up for the fact that you can't index a string
like an array of characters.

Jeremy

On Fri, Jan 23, 2009 at 5:16 PM, Chris Erskine <chris@...> wrote:
One of the things that I would do with pointers was for strings with delimiters, you would null out the delimiter and by using pointers, you could point to the start of the string without having to copy the data into new fields. There are a number of other uses that they can be used for but that was the one I was thinking about when Joseph talked about breaking up the XML files.



Chris


fellatedone
 

Fantastic post. Thank you.

-JOHN

--- In Crestron@..., Chris Erskine <chris@...> wrote:

Over the years, I have programmed in many different languages
starting with assembler and moving up into what are called 4GL and
true Object Oriented languages. They each have their strong points
and their weaknesses. Each have places where they are the better
language for the usage. C was designed to be a higher level language
than assembler but still allow some of the power of assembler with its
pointers.

For some, programming languages are more of a religious war (like
with OS's) where their language or way of programming is the best or
only way. For the good programmers, a language is just a tool where
they find the strengths and weaknesses and how to use it for the job
being done.

Simpl and S+ are just programming languages. We need to learn their
strengths and weaknesses just like any other tool. There are some
places where Simpl is the right tool and some where S+ is the right
one. Since Simpl is the "native" language of the Crestron processors
and is required for everything you do programming in the Crestron
environment, it is the one that most time should be spent on. When
you find places S+ is the better language, use it but also understand
where it should and should not be used.

I know that in this environment, I am not one of your 'cream of the
crop' programmers. I am still trying to learn this envirnoment. The
way this type of group works isif you can help, do so. Some of the
times when you try to help, you find you are wrong but most of the
times, you are not. Some of the times, you find that you may be right
but there is a better way.

Chris


-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On
Behalf Of Matt
Sent: Friday, January 23, 2009 5:10 PM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined
array elements.

...I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors, programmers
do" ;-)


Hey, I resemble that comment. ;)

But in all honesty, I think the majority of Crestron programmers
don't have procedural backgrounds, and don't really need to, it's not
a procedural language, some people might even say that it's not MEANT
to be programmed with S+.

A lot of the programmers here are the 'cream of the crop' and I for
one appreciate the help, but I also like to think I help as well.
Sure, not with pointers or 'dynamic memory assignment' or what-have-
you, and also make syntax errors that I ask about, but helping out
with a 'I can't figure out how the example checksum is calculated' is
good too...right? ;)




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in
the Database area.
Yahoo!
Groups Links


Chris Erskine
 

Over the years, I have programmed in many different languages starting with assembler and moving up into what are called 4GL and true Object Oriented languages. They each have their strong points and their weaknesses. Each have places where they are the better language for the usage. C was designed to be a higher level language than assembler but still allow some of the power of assembler with its pointers.

For some, programming languages are more of a religious war (like with OS's) where their language or way of programming is the best or only way. For the good programmers, a language is just a tool where they find the strengths and weaknesses and how to use it for the job being done.

Simpl and S+ are just programming languages. We need to learn their strengths and weaknesses just like any other tool. There are some places where Simpl is the right tool and some where S+ is the right one. Since Simpl is the "native" language of the Crestron processors and is required for everything you do programming in the Crestron environment, it is the one that most time should be spent on. When you find places S+ is the better language, use it but also understand where it should and should not be used.

I know that in this environment, I am not one of your 'cream of the crop' programmers. I am still trying to learn this envirnoment. The way this type of group works isif you can help, do so. Some of the times when you try to help, you find you are wrong but most of the times, you are not. Some of the times, you find that you may be right but there is a better way.

Chris

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Matt
Sent: Friday, January 23, 2009 5:10 PM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined array elements.

...I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors, programmers
do" ;-)


Hey, I resemble that comment. ;)

But in all honesty, I think the majority of Crestron programmers
don't have procedural backgrounds, and don't really need to, it's not
a procedural language, some people might even say that it's not MEANT
to be programmed with S+.

A lot of the programmers here are the 'cream of the crop' and I for
one appreciate the help, but I also like to think I help as well.
Sure, not with pointers or 'dynamic memory assignment' or what-have-
you, and also make syntax errors that I ask about, but helping out
with a 'I can't figure out how the example checksum is calculated' is
good too...right? ;)




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links


Matt
 

...I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors, programmers
do" ;-)


Hey, I resemble that comment. ;)

But in all honesty, I think the majority of Crestron programmers
don't have procedural backgrounds, and don't really need to, it's not
a procedural language, some people might even say that it's not MEANT
to be programmed with S+.

A lot of the programmers here are the 'cream of the crop' and I for
one appreciate the help, but I also like to think I help as well.
Sure, not with pointers or 'dynamic memory assignment' or what-have-
you, and also make syntax errors that I ask about, but helping out
with a 'I can't figure out how the example checksum is calculated' is
good too...right? ;)


Joseph K. Vossen
 

that's how many implementations of strtok(3) work.

On Friday 23 January 2009 06:18 pm, you wrote:
Oh Duh... Sorry, I forgot the whole part about being able to point to
individual character positions in a "string".

Makes much more sense


 

Oh Duh... Sorry, I forgot the whole part about being able to point to individual character positions in a "string".

Makes much more sense

--
Lincoln King-Cliby, CTS
Applications Engineer
ControlWorks Consulting, LLC
V: 440.729.4640 x1107 F: 440.729.0884 I:
Crestron Authorized Independent Programmer

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Chris Erskine
Sent: Friday, January 23, 2009 6:17 PM
To: Crestron@...
Subject: RE: RE: [Crestron] Re: Question on finding the number of defined array elements.

One of the things that I would do with pointers was for strings with delimiters, you would null out the delimiter and by using pointers, you could point to the start of the string without having to copy the data into new fields. There are a number of other uses that they can be used for but that was the one I was thinking about when Joseph talked about breaking up the XML files.



Chris


-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Lincoln King-Cliby
Sent: Friday, January 23, 2009 4:08 PM
To: 'Crestron@...'
Subject: RE: [Crestron] Re: Question on finding the number of defined array elements.

Isn't' that why you pass strings by reference unless you have a good reason for passing them by value (or you're dealing with one of the S+ quirks that won't allow a passing byref, like IIRC, a serial input)?

Or would pointers open up another advantageous option that I'm forgetting at the moment (it's been far too long since the last time I played with a language the formally supported pointers :(... but they are uber cool. Took me most of my first semester of AP CompSci in high school to figure the point out, but after that... wow!)

Lincoln

--
Lincoln King-Cliby, CTS
Applications Engineer
ControlWorks Consulting, LLC
V: 440.729.4640 x1107 F: 440.729.0884 I:
Crestron Authorized Independent Programmer


-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Chris Erskine
Sent: Friday, January 23, 2009 11:12 AM
To: Crestron@...
Subject: RE: [Crestron] Re: Question on finding the number of defined array elements.

I agree that not only would your code be more compact but more efficient since you would not have to be copying data around all over. On the other hand, pointers would cause so much more problems in the code that systems would be crashing all over. Crestron would require better TB personnel and better tools since you would need a debugger that would let you step through the S+ code when it was running.



Chris

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Joseph K. Vossen
Sent: Friday, January 23, 2009 9:06 AM
To: Crestron@...
Subject: Re: [Crestron] Re: Question on finding the number of defined array elements.

agreed...in my non-Crestron circle of travels in the past, I have found that a *good* understanding of pointers separates the good programmers from the great ones. And then when you jump into function pointers, that opens up a whole new world of fun.....





having pointers in SIMPL+ would benefit, for example, those tasks that perform a *lot* of parsing, such as busting up XML pages. Sure one can do it now with what is available, I just think the code would be a bit more compact, IMHO

-----Original Message-----
From: fooguy89 <fooguy89@...>
Sent: Jan 23, 2009 10:53 AM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined array elements.

I'm pretty sure the reason Crestron doesn't do Pointers is because of
support. They tend to perform a lot of support that doesn't seem to
be "their problem" - issues that are clearly programming mistakes, but
they do try to help resolve them (I know people knock TB for a lot,
but I mean they do try to be helpful if you get the right folks).

Can you just imagine the chaos of newbies trying to use pointers,
overwriting memory, blah blah blah, and Crestron trying to suck it up
and fix it/teach them?

As a professional programmer, sure, it would be great to have, but I
can definitely see why many things are limited.

Sometimes I don't understand the need to try to fix and assist with
blatant programming problems (If you were to call microsoft and whine
about how your system crashed because you did a NULL pointer access or
overwrite the bounds of your array, they'd probably just be like
"Uh....GO FIND AND FIX IT YOURSELF!!")


--- In Crestron@..., Joseph K. Vossen <jkv@...> wrote:

the semi-colon after the if() is a valid statement from the parser's
point of view; it just doesn't do what you want/expect

here is a simple example of how that is useful; the following 'C'
code copies a NULL-terminated string, where 'p' points to the destination and
'q' points to the source:. The while() terminates when the NULL terminating
byte is hit.

while (*p++ = *q++)
; // <- note lone semi-colon

ya' just gotta love pointers...sure wish SIMPL+ had 'em.......

On Friday 23 January 2009 12:33 am, you wrote:
I would have expected to see a compiler error on the fatal ; at the
end of an IF statement.

True, but I always put them in so that if I do add another line I
don't mess up the execution order/nesting. (Didn't see the ; -
fatal, but a trace should have shown 10 outputs rather than just 1.)

Lindsay


------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links


Chris Erskine
 

One of the things that I would do with pointers was for strings with delimiters, you would null out the delimiter and by using pointers, you could point to the start of the string without having to copy the data into new fields. There are a number of other uses that they can be used for but that was the one I was thinking about when Joseph talked about breaking up the XML files.



Chris

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Lincoln King-Cliby
Sent: Friday, January 23, 2009 4:08 PM
To: 'Crestron@...'
Subject: RE: [Crestron] Re: Question on finding the number of defined array elements.

Isn't' that why you pass strings by reference unless you have a good reason for passing them by value (or you're dealing with one of the S+ quirks that won't allow a passing byref, like IIRC, a serial input)?

Or would pointers open up another advantageous option that I'm forgetting at the moment (it's been far too long since the last time I played with a language the formally supported pointers :(... but they are uber cool. Took me most of my first semester of AP CompSci in high school to figure the point out, but after that... wow!)

Lincoln

--
Lincoln King-Cliby, CTS
Applications Engineer
ControlWorks Consulting, LLC
V: 440.729.4640 x1107 F: 440.729.0884 I:
Crestron Authorized Independent Programmer


-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Chris Erskine
Sent: Friday, January 23, 2009 11:12 AM
To: Crestron@...
Subject: RE: [Crestron] Re: Question on finding the number of defined array elements.

I agree that not only would your code be more compact but more efficient since you would not have to be copying data around all over. On the other hand, pointers would cause so much more problems in the code that systems would be crashing all over. Crestron would require better TB personnel and better tools since you would need a debugger that would let you step through the S+ code when it was running.



Chris

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Joseph K. Vossen
Sent: Friday, January 23, 2009 9:06 AM
To: Crestron@...
Subject: Re: [Crestron] Re: Question on finding the number of defined array elements.

agreed...in my non-Crestron circle of travels in the past, I have found that a *good* understanding of pointers separates the good programmers from the great ones. And then when you jump into function pointers, that opens up a whole new world of fun.....




having pointers in SIMPL+ would benefit, for example, those tasks that perform a *lot* of parsing, such as busting up XML pages. Sure one can do it now with what is available, I just think the code would be a bit more compact, IMHO

-----Original Message-----
From: fooguy89 <fooguy89@...>
Sent: Jan 23, 2009 10:53 AM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined array elements.

I'm pretty sure the reason Crestron doesn't do Pointers is because of
support. They tend to perform a lot of support that doesn't seem to
be "their problem" - issues that are clearly programming mistakes, but
they do try to help resolve them (I know people knock TB for a lot,
but I mean they do try to be helpful if you get the right folks).

Can you just imagine the chaos of newbies trying to use pointers,
overwriting memory, blah blah blah, and Crestron trying to suck it up
and fix it/teach them?

As a professional programmer, sure, it would be great to have, but I
can definitely see why many things are limited.

Sometimes I don't understand the need to try to fix and assist with
blatant programming problems (If you were to call microsoft and whine
about how your system crashed because you did a NULL pointer access or
overwrite the bounds of your array, they'd probably just be like
"Uh....GO FIND AND FIX IT YOURSELF!!")


--- In Crestron@..., Joseph K. Vossen <jkv@...> wrote:

the semi-colon after the if() is a valid statement from the parser's
point of view; it just doesn't do what you want/expect

here is a simple example of how that is useful; the following 'C'
code copies a NULL-terminated string, where 'p' points to the destination and
'q' points to the source:. The while() terminates when the NULL terminating
byte is hit.

while (*p++ = *q++)
; // <- note lone semi-colon

ya' just gotta love pointers...sure wish SIMPL+ had 'em.......

On Friday 23 January 2009 12:33 am, you wrote:
I would have expected to see a compiler error on the fatal ; at the
end of an IF statement.

True, but I always put them in so that if I do add another line I
don't mess up the execution order/nesting. (Didn't see the ; -
fatal, but a trace should have shown 10 outputs rather than just 1.)

Lindsay


------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links


 

Isn't' that why you pass strings by reference unless you have a good reason for passing them by value (or you're dealing with one of the S+ quirks that won't allow a passing byref, like IIRC, a serial input)?

Or would pointers open up another advantageous option that I'm forgetting at the moment (it's been far too long since the last time I played with a language the formally supported pointers :(... but they are uber cool. Took me most of my first semester of AP CompSci in high school to figure the point out, but after that... wow!)

Lincoln

--
Lincoln King-Cliby, CTS
Applications Engineer
ControlWorks Consulting, LLC
V: 440.729.4640 x1107 F: 440.729.0884 I:
Crestron Authorized Independent Programmer

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Chris Erskine
Sent: Friday, January 23, 2009 11:12 AM
To: Crestron@...
Subject: RE: [Crestron] Re: Question on finding the number of defined array elements.

I agree that not only would your code be more compact but more efficient since you would not have to be copying data around all over. On the other hand, pointers would cause so much more problems in the code that systems would be crashing all over. Crestron would require better TB personnel and better tools since you would need a debugger that would let you step through the S+ code when it was running.



Chris

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of Joseph K. Vossen
Sent: Friday, January 23, 2009 9:06 AM
To: Crestron@...
Subject: Re: [Crestron] Re: Question on finding the number of defined array elements.

agreed...in my non-Crestron circle of travels in the past, I have found that a *good* understanding of pointers separates the good programmers from the great ones. And then when you jump into function pointers, that opens up a whole new world of fun.....



having pointers in SIMPL+ would benefit, for example, those tasks that perform a *lot* of parsing, such as busting up XML pages. Sure one can do it now with what is available, I just think the code would be a bit more compact, IMHO

-----Original Message-----
From: fooguy89 <fooguy89@...>
Sent: Jan 23, 2009 10:53 AM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined array elements.

I'm pretty sure the reason Crestron doesn't do Pointers is because of
support. They tend to perform a lot of support that doesn't seem to
be "their problem" - issues that are clearly programming mistakes, but
they do try to help resolve them (I know people knock TB for a lot,
but I mean they do try to be helpful if you get the right folks).

Can you just imagine the chaos of newbies trying to use pointers,
overwriting memory, blah blah blah, and Crestron trying to suck it up
and fix it/teach them?

As a professional programmer, sure, it would be great to have, but I
can definitely see why many things are limited.

Sometimes I don't understand the need to try to fix and assist with
blatant programming problems (If you were to call microsoft and whine
about how your system crashed because you did a NULL pointer access or
overwrite the bounds of your array, they'd probably just be like
"Uh....GO FIND AND FIX IT YOURSELF!!")


--- In Crestron@..., Joseph K. Vossen <jkv@...> wrote:

the semi-colon after the if() is a valid statement from the parser's
point of view; it just doesn't do what you want/expect

here is a simple example of how that is useful; the following 'C'
code copies a NULL-terminated string, where 'p' points to the destination and
'q' points to the source:. The while() terminates when the NULL terminating
byte is hit.

while (*p++ = *q++)
; // <- note lone semi-colon

ya' just gotta love pointers...sure wish SIMPL+ had 'em.......

On Friday 23 January 2009 12:33 am, you wrote:
I would have expected to see a compiler error on the fatal ; at the
end of an IF statement.

True, but I always put them in so that if I do add another line I
don't mess up the execution order/nesting. (Didn't see the ; -
fatal, but a trace should have shown 10 outputs rather than just 1.)

Lindsay


------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links




------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links


 

That that is almost exactly what came out of conversation I had with someone fairly high up in the software world of things an Infocomm or two ago, and also the difficulty of protecting the relative "sandbox" that SIMPL+ plays in.

Lincoln

--
Lincoln King-Cliby, CTS
Applications Engineer
ControlWorks Consulting, LLC
V: 440.729.4640 x1107 F: 440.729.0884 I:
Crestron Authorized Independent Programmer

-----Original Message-----
From: Crestron@... [mailto:Crestron@...] On Behalf Of fooguy89
Sent: Friday, January 23, 2009 10:53 AM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined array elements.

I'm pretty sure the reason Crestron doesn't do Pointers is because of
support. They tend to perform a lot of support that doesn't seem to
be "their problem" - issues that are clearly programming mistakes, but
they do try to help resolve them (I know people knock TB for a lot,
but I mean they do try to be helpful if you get the right folks).

Can you just imagine the chaos of newbies trying to use pointers,
overwriting memory, blah blah blah, and Crestron trying to suck it up
and fix it/teach them?

As a professional programmer, sure, it would be great to have, but I
can definitely see why many things are limited.

Sometimes I don't understand the need to try to fix and assist with
blatant programming problems (If you were to call microsoft and whine
about how your system crashed because you did a NULL pointer access or
overwrite the bounds of your array, they'd probably just be like
"Uh....GO FIND AND FIX IT YOURSELF!!")





--- In Crestron@..., Joseph K. Vossen <jkv@...> wrote:

the semi-colon after the if() is a valid statement from the parser's
point of
view; it just doesn't do what you want/expect

here is a simple example of how that is useful; the following 'C'
code copies
a NULL-terminated string, where 'p' points to the destination and
'q' points
to the source:. The while() terminates when the NULL terminating
byte is hit.

while (*p++ = *q++)
; // <- note lone
semi-colon

ya' just gotta love pointers...sure wish SIMPL+ had 'em.......

On Friday 23 January 2009 12:33 am, you wrote:
I would have expected to see a compiler error on the fatal ; at the
end of an IF statement.

True, but I always put them in so that if I do add another line I
don't mess up the execution order/nesting. (Didn't see the ; -
fatal, but a trace should have shown 10 outputs rather than just 1.)

Lindsay
[snip]


------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links


 

Well, even if you pass your array ByRef, *every* time you access an
array element, bounds checking is done. I think that speed hit,
whatever it amounts to being in their implementation, outweighs
finding an array overrun. As all of us who have programmed in C know,
just because you overrun the array "now" doesn't mean you find the
error now. You could run into the after effect minutes, days, or
years from the time it happened!

--- In Crestron@..., "Oliver Hall" <oliver.hall@...> wrote:

I agree, that in the right hands, pointers are extremely powerful,
but I feel Crestron have chosen wisely here.

As foo's already said, the potential for misuse of pointers would
open us up to a world of pain. I'm not knocking anyone here; we all
have to start somewhere, but there do appear to be a lot of guys
programming systems with some pretty shaky foundations in procedural
languages, and even simple syntactic issues (like the root of this
thread) could wreak havoc scrambling your processor's brains. So I
suppose you could argue "Pointers don't kill processors, programmers
do" ;-) Anyway - anyone who's had to debug bad pointer arithmetic
knows what a time-consuming process it can be, and that's on your own
code - it's 100x harder when it's someone else's.

The efficiency argument can be mitigated too - you can always use
ByRef in your function declarations (in fact, you can't avoid it with
STRING). I've written an XML parser that doesn't move the XML
document at all (though it does mean creating a lot of markers...
which I guess are just my version of (safe?) pointers).

This is where foo pipes up to say that Crestron's implementation of
ByRef does actually make a copy the data 8)

Now... if they'd just implement multiple-inheritance in S+ (*JOKING!*)

Ol

--- In Crestron@..., "Joseph K. Vossen" <jkv@> wrote:

agreed...in my non-Crestron circle of travels in the past, I have
found that a *good* understanding of pointers separates the good
programmers from the great ones. And then when you jump into
function pointers, that opens up a whole new world of fun.....

having pointers in SIMPL+ would benefit, for example, those tasks
that perform a *lot* of parsing, such as busting up XML pages. Sure
one can do it now with what is available, I just think the code would
be a bit more compact, IMHO

-----Original Message-----
From: fooguy89 <fooguy89@>
Sent: Jan 23, 2009 10:53 AM
To: Crestron@...
Subject: [Crestron] Re: Question on finding the number of defined
array elements.

I'm pretty sure the reason Crestron doesn't do Pointers is because
of
support. They tend to perform a lot of support that doesn't seem
to
be "their problem" - issues that are clearly programming mistakes,
but
they do try to help resolve them (I know people knock TB for a lot,
but I mean they do try to be helpful if you get the right folks).

Can you just imagine the chaos of newbies trying to use pointers,
overwriting memory, blah blah blah, and Crestron trying to suck it
up
and fix it/teach them?

As a professional programmer, sure, it would be great to have, but
I
can definitely see why many things are limited.

Sometimes I don't understand the need to try to fix and assist with
blatant programming problems (If you were to call microsoft and
whine
about how your system crashed because you did a NULL pointer
access or
overwrite the bounds of your array, they'd probably just be like
"Uh....GO FIND AND FIX IT YOURSELF!!")


--- In Crestron@..., Joseph K. Vossen <jkv@> wrote:

the semi-colon after the if() is a valid statement from the
parser's
point of view; it just doesn't do what you want/expect

here is a simple example of how that is useful; the following 'C'
code copies a NULL-terminated string, where 'p' points to the
destination and
'q' points to the source:. The while() terminates when the NULL
terminating
byte is hit.

while (*p++ = *q++)
; // <- note
lone semi-colon

ya' just gotta love pointers...sure wish SIMPL+ had 'em.......

On Friday 23 January 2009 12:33 am, you wrote:
I would have expected to see a compiler error on the fatal ;
at the
end of an IF statement.

True, but I always put them in so that if I do add another
line I
don't mess up the execution order/nesting. (Didn't see
the ; -
fatal, but a trace should have shown 10 outputs rather than
just 1.)

Lindsay


Chip Moody
 

That seems pretty legit - thanks Jeremy.

Of course, now I just feel guilty that I'm wasting an extra 1k of
volatile memory in my module... :)

- Chip


--- In Crestron@..., Jeremy Weatherford <xidus.net@...> wrote:

The result of mid() seems to get stored in a temporary variable even
if you just assign it to a local variable. Here's an example from
Crestron's BKParser.usp, line 245:

Temp1$ = Mid(Temp$[4], 2, (Temp[4] -2)); //Get Name string

And here's what it compiles to:

UpdateSourceCodeLine( INSTANCE_PTR( S2_BKParser ), 245 );
FormatString ( INSTANCE_PTR( S2_BKParser ) ,
LOCAL_STRING_STRUCT( __FN_DST_STR__1 ) ,2 , "%s" , Mid (
LOCAL_STRING_STRUCT( __FN_DST_STR__ ) , GetStringArrayElement (
INSTANCE_PTR( S2_BKParser ), LOCAL_STRING_ARRAY( __TEMP$ ) , 4
) , 2, (GET_LOCAL_INTARRAY_VALUE( S2_BKParser, __TEMP, 0, 4 ) - 2))
) ;
FormatString ( INSTANCE_PTR( S2_BKParser ) ,
LOCAL_STRING_STRUCT( __TEMP1$ ) ,2 , "%s" , __FN_DST_STR__1 ) ;

In this case, there's a temporary variable named __FN_DST_STR__1 used
for the result of Mid(). I seem to remember seeing string overflow
error messages for variables with names like that. I'm guessing
they're generated for any kind of string expression, although it seems
odd to use it for a simple assignment. Generated code is never the
paragon of efficiency, though...

Jeremy

On Fri, Jan 23, 2009 at 11:53 AM, Chip Moody <cfm@...> wrote:

This is actually something I was wondering about when I made the XM
Now Playing module, and just couldn't bring myself to write TBTS
on this.

In the XM module, I take the result of a MID function and pass it to
one of my own functions that in turn manipulates the results of the
MID and returns the result of THAT manipulation.

If I could abbreviate/abstract it, it might look something like this:

STRING_FUNCTION Fudge (STRING src$)
{
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",src$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

PUSH Go
{
tx$ = Fudge (MID(SomeExistingStringVar$,3,6));
}

My mindset was that the result of MID doesn't exist as a variable,
so I can't really mess around with the contents of that result like I
show in that snippet up there. So in the ACTUAL module, one of the
first things that happens inside Fudge is I copy "src$" into local
variable "temp$", then work on temp$ exclusively:

STRING_FUNCTION Fudge (STRING src$)
{
temp$ = src$;
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",temp$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

Does that make sense? Does anyone know for certain if what I did
was required, or does the result of MID (or any other string function
for that matter) exist in some malleable state that I can operate on?

Thanks,
- Chip


--- In Crestron@..., "Oliver Hall" <oliver.hall@> wrote:

This is where foo pipes up to say that Crestron's implementation of
ByRef does actually make a copy the data 8)

------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in
the Database area.
Yahoo!
Groups Links





--
Jeremy Weatherford


 

Well, in the case of something like C, bad pointer arithmetic and bad
indices of arrays are just as bad. At least with SIMPL+ arrays, sure
you should check your indices to make sure that you're doing the right
thing, but if you over/underrun, at least you don't write into other
application memory, it issues an error and you can later try to track
it down.


--- In Crestron@..., Jeremy Weatherford <xidus.net@...> wrote:

What would you do with pointers that you can't do with array indexes?
Function arguments are already passed by reference, so what's this
"copying data around all over"?

It's easy to bounds-check array indexes to keep a program from doing
bad things when it screws up. It's hard to check pointer arithmetic.
It's also hard to get dynamic memory allocation right. I think
Crestron has struck a good balance with SIMPL+'s features, power, and
robustness.

Jeremy


On Fri, Jan 23, 2009 at 10:12 AM, Chris Erskine <chris@...> wrote:
I agree that not only would your code be more compact but more
efficient since you would not have to be copying data around all over.
On the other hand, pointers would cause so much more problems in the
code that systems would be crashing all over. Crestron would require
better TB personnel and better tools since you would need a debugger
that would let you step through the S+ code when it was running.


Jeremy Weatherford
 

The result of mid() seems to get stored in a temporary variable even
if you just assign it to a local variable. Here's an example from
Crestron's BKParser.usp, line 245:

Temp1$ = Mid(Temp$[4], 2, (Temp[4] -2)); //Get Name string

And here's what it compiles to:

UpdateSourceCodeLine( INSTANCE_PTR( S2_BKParser ), 245 );
FormatString ( INSTANCE_PTR( S2_BKParser ) ,
LOCAL_STRING_STRUCT( __FN_DST_STR__1 ) ,2 , "%s" , Mid (
LOCAL_STRING_STRUCT( __FN_DST_STR__ ) , GetStringArrayElement (
INSTANCE_PTR( S2_BKParser ), LOCAL_STRING_ARRAY( __TEMP$ ) , 4
) , 2, (GET_LOCAL_INTARRAY_VALUE( S2_BKParser, __TEMP, 0, 4 ) - 2))
) ;
FormatString ( INSTANCE_PTR( S2_BKParser ) ,
LOCAL_STRING_STRUCT( __TEMP1$ ) ,2 , "%s" , __FN_DST_STR__1 ) ;

In this case, there's a temporary variable named __FN_DST_STR__1 used
for the result of Mid(). I seem to remember seeing string overflow
error messages for variables with names like that. I'm guessing
they're generated for any kind of string expression, although it seems
odd to use it for a simple assignment. Generated code is never the
paragon of efficiency, though...

Jeremy

On Fri, Jan 23, 2009 at 11:53 AM, Chip Moody <cfm@...> wrote:

This is actually something I was wondering about when I made the XM
Now Playing module, and just couldn't bring myself to write TBTS on this.

In the XM module, I take the result of a MID function and pass it to
one of my own functions that in turn manipulates the results of the
MID and returns the result of THAT manipulation.

If I could abbreviate/abstract it, it might look something like this:

STRING_FUNCTION Fudge (STRING src$)
{
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",src$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

PUSH Go
{
tx$ = Fudge (MID(SomeExistingStringVar$,3,6));
}

My mindset was that the result of MID doesn't exist as a variable,
so I can't really mess around with the contents of that result like I
show in that snippet up there. So in the ACTUAL module, one of the
first things that happens inside Fudge is I copy "src$" into local
variable "temp$", then work on temp$ exclusively:

STRING_FUNCTION Fudge (STRING src$)
{
temp$ = src$;
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",temp$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

Does that make sense? Does anyone know for certain if what I did
was required, or does the result of MID (or any other string function
for that matter) exist in some malleable state that I can operate on?

Thanks,
- Chip


--- In Crestron@..., "Oliver Hall" <oliver.hall@...> wrote:

This is where foo pipes up to say that Crestron's implementation of
ByRef does actually make a copy the data 8)

------------------------------------



Check out the Files area for useful modules, documents, and drivers.

A contact list of Crestron dealers and programmers can be found in the Database area.
Yahoo! Groups Links



--
Jeremy Weatherford


Matt
 

Touche


Why?

You're just saying if some condition is true, then do nothing. Not
exactly something I'd typically see someone programming, but it *IS*
perfectly valid.


--- In Crestron@..., "Matt" <mjrtoo@> wrote:

I would have expected to see a compiler error on the fatal ; at
the
end of an IF statement.



True, but I always put them in so that if I do add another line
I
don't mess up the execution order/nesting. (Didn't see the ; -
fatal,
but a trace should have shown 10 outputs rather than just 1.)

Lindsay

--- In Crestron@..., "Matt" <mjrtoo@> wrote:

Thanks Lindsay and Chip, it's always puntuation isn't it. If
I
were
to remove the trace statement, could you use no brackets? If
the
brackets are required, I guess there's another error in the
help
file.



Hi Matt,

You need to put the statements after the IF in {}.

Lindsay

--- In Crestron@..., "Matt" <mjrtoo@> wrote:

I'm messing around with an upcoming project, and am
looking
to
determine the number of elements a string array has been
assigned
in
Simpl. Looking at S+ I see the directive isSignalDefined
().
I
have
the following code (not complete).

STRING_INPUT in$[10][25];

Function Main()
{
FOR(i = 10 to 1 Step -1)
{
IF(IsSignalDefined(in$[i]));
TRACE("i = %d", i);
BREAK;
}
}

Within Simpl, I have only two strings expanded on the
symbol,
but
NumSources always = 10, I was expecting to see 1.

Is this the correct approach and/or any advice on what's
incorrect?


Chip Moody
 

That was a potential guess for me, but I didn't know if it was one
of those "iffy" situations in the S+ compiler that might bite me in
the ass down the road, y'know?

Maybe I'll get off my butt and see what happens if I change it over
the weekend...

- Chip

P.S. Oliver - thanks for your answer too, and enjoy the beer!!


--- In Crestron@..., "Joseph K. Vossen" <jkv@...> wrote:

[snip]

My mindset was that the result of MID doesn't exist as a variable,
well, actually it does. I can't say for certain with the SIMPL+
compiler, but all of the compilers I have worked on will generate a
"temporary" whose type/size is "local" to the block and is used to
hold the value for cases like this. The temporary is generated on the
stack so it will "disappear" when you go out of scope. You can't
reference it directly (by name) since it is typically generated
above/below (depends on how the stack frame is maintained) the
variables that the programmer declared for that block.

[more snip]


Joseph K. Vossen
 

[snip]

My mindset was that the result of MID doesn't exist as a variable,
well, actually it does. I can't say for certain with the SIMPL+ compiler, but all of the compilers I have worked on will generate a "temporary" whose type/size is "local" to the block and is used to hold the value for cases like this. The temporary is generated on the stack so it will "disappear" when you go out of scope. You can't reference it directly (by name) since it is typically generated above/below (depends on how the stack frame is maintained) the variables that the programmer declared for that block.

[more snip]


 

Disclaimer: TOTAL GUESS!

I'd say that in the case of a function that *returns* a value, that
value must be created on the stack. So your MID is creating a new
string. That "new" string is then either assigned to a string
variable or returned to the calling function.

So: you're not passing ByRef in this case, but essentially "returning
ByVal". Meaning, you don't need to use temp$.

The MID(SomeExisting...) is creating a new string, passing it ByRef
to Fudge, which then modifies that *new* string (by the REMOVE()).

I think...

I'll have to test that theory - but not now... it's Beer O'Clock!

Enjoy your weekends everyone!
Ol

--- In Crestron@..., "Chip Moody" <cfm@...> wrote:


This is actually something I was wondering about when I made the
XM
Now Playing module, and just couldn't bring myself to write TBTS on
this.

In the XM module, I take the result of a MID function and pass it
to
one of my own functions that in turn manipulates the results of the
MID and returns the result of THAT manipulation.

If I could abbreviate/abstract it, it might look something like
this:

STRING_FUNCTION Fudge (STRING src$)
{
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",src$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

PUSH Go
{
tx$ = Fudge (MID(SomeExistingStringVar$,3,6));
}

My mindset was that the result of MID doesn't exist as a variable,
so I can't really mess around with the contents of that result like
I
show in that snippet up there. So in the ACTUAL module, one of the
first things that happens inside Fudge is I copy "src$" into local
variable "temp$", then work on temp$ exclusively:

STRING_FUNCTION Fudge (STRING src$)
{
temp$ = src$;
// Among other things, do something along these lines:
Garbage$ = REMOVE(";",temp$);
// Blah blah, more code here...
RETURN (MyProcessedString$);
}

Does that make sense? Does anyone know for certain if what I did
was required, or does the result of MID (or any other string
function
for that matter) exist in some malleable state that I can operate
on?

Thanks,
- Chip


--- In Crestron@..., "Oliver Hall" <oliver.hall@> wrote:

This is where foo pipes up to say that Crestron's implementation
of
ByRef does actually make a copy the data 8)