Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Function(s) used implicit in PRINT statemen t?

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
Per Svensson

Bascom Member



Joined: 03 Oct 2004
Posts: 235
Location: Gothenburg, Sweden

sweden.gif
PostPosted: Fri Apr 08, 2016 2:49 pm    Post subject: Function(s) used implicit in PRINT statemen t? Reply with quote

A genaral question that I think many of us would like to know about.

Ar there any rules for when it is ok to use function calls inside a PRINT statment?

That is: PRINT #CHNL, ; variable ; string; CALL ...
where CALL might be HEX(), BIN(), LEFT(), MID(), MAX(), MIN(), STRING(), STR(), VAL(), ,TRIM() etcetra

The easy answer is of course - No you should never do that kind of constructs!
But I have experienced that BIN(), HEX(), and VAL() Always seem to be ok. It works and nothing seem to be disturbed by it as long as there is enough stacks.

So are there any rules in general, like where in the parameter list functions may show up, or how many there may be?
Which ones were designed for use with PRINT in mind?

Would be interesting to know this, as we all want to use functions that way, but hardly dare to.


Friday! - don't forget to go home folks! Smile
/Per

(BASCOM-AVR version : 2080.001 , Latest : 2.0.7.8 )
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Apr 08, 2016 3:00 pm    Post subject: Reply with quote

I do not see the point to use val() or Str() in combination with PRINT since PRINT handles conversion automatic.
hex() and bin() are supported and should not cause any problem. All others should work too but notice that result might not be what you expect.
If you have a string loaded with "5000" , the val() will convert it, but since there is no explicit type defined, the result could be wrong so i would not do that. for instance, if the string is "12.3" the val() does not check for that.

_________________
Mark
Back to top
View user's profile Visit poster's website
Per Svensson

Bascom Member



Joined: 03 Oct 2004
Posts: 235
Location: Gothenburg, Sweden

sweden.gif
PostPosted: Fri Apr 08, 2016 3:18 pm    Post subject: Reply with quote

Ok Mark,

I agree that some of the functions like VAL() are stupid examples as there are better ways to do it.
But my question is more general that that.

Let's take LEFT() or MID(). These are calls that you might want to do implicit, but it is not obvious if
that is allowed or not.

I understand that it (like you examplified) can be hard to forsee the outcome of some commands.
Let's put it this way then:

Can we get a list of those calls that should be safe to use? (like Hex and Bin)
Could be put in the PRINT help.

/Per
Back to top
View user's profile Visit poster's website
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5921
Location: Holland

blank.gif
PostPosted: Fri Apr 08, 2016 3:36 pm    Post subject: Reply with quote

no there will not be such a list since the idea is that it should work. if it doesnt, send a small sample to support.
_________________
Mark
Back to top
View user's profile Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum