Can the PRINT command halt program execution??


Today 08:45
Forum: The Lounge
Starter: normnet
Views: 0
Replies: 2
Yesterday 15:38
Forum: Proton Plus Compiler v3
Starter: gdesantis
Views: 0
Replies: 4
+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Junior Member Klr650's Avatar
    Join Date
    Jun 2013
    Posts
    19
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    452.11 MB

    0 Not allowed!

    Default Can the PRINT command halt program execution??

    This line in my program does what it says on the tin - it clears the screen then prints the value of a float variable ftemp
    to one decimal place.

    Cls:Print At 1,1, dec1 ftemp, " C"

    if I change the line to:

    Cls:Print At 1,1, sign,dec1 ftemp, " C" Where 'sign' is a one character string variable containing + or - .

    then the screen clears but nothing is printed and the program halts (the next line flashes an LED but it doesn't flash).

    Am I going bonkers??

  2. #2
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,205
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    456.72 MB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

    Hi,
    I doubt it makes any difference but I would have the CLS on a separate row.

    I think the issue is with the sign, how are you making it a + or -?
    Personally I would do something like
    Cls
    if sign = 1 then Print At 1,1, "+",dec1 ftemp, " C"
    else Print At 1,1, "-",dec1 ftemp, " C"

    Regards,
    Bob

  3. #3
    Junior Member Klr650's Avatar
    Join Date
    Jun 2013
    Posts
    19
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    452.11 MB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

    Thanks for that Bob (2-stroke man!), your suggestion does work.

    This is worrying though - I find this programming lark hard enough as it is without coming across things like this. No warning from the compiler and the program just stops when you would think there is nothing wrong!

    Cheers.

  4. #4
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,205
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    456.72 MB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

    Hi,
    If it is not too long post your code (or a small example) that shows the issue and I will take a look if I get the time.

    Regards,
    Bob

  5. #5
    Prolific Poster towlerg's Avatar
    Join Date
    Mar 2012
    Posts
    1,857
    Thumbs Up
    Received: 163
    Given: 162
    Total Downloaded
    3.24 GB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

    FWIW there realy is little point in creating multiple statements on a single line. The compiler breaks them down to their component parts anyway so you're not saving any code space, just potentially confusing the compiler.

    C programmers do it show how clever they and to confuse everyone.
    George

  6. #6
    Prolific Poster joesaliba's Avatar
    Join Date
    Sep 2004
    Posts
    2,375
    Thumbs Up
    Received: 86
    Given: 23
    Total Downloaded
    4.04 GB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

    If `sign' is a variable then you can do the following: -

    sign = $2D ' This is for a `-' sign

    or

    sign = $2B ' This is for a `+' sign

    Then: -

    Cls
    Print At 1,1, sign , dec1 ftemp, " C"
    Regards

    Joseph

  7. #7
    Junior Member Klr650's Avatar
    Join Date
    Jun 2013
    Posts
    19
    Thumbs Up
    Received: 2
    Given: 0
    Total Downloaded
    452.11 MB

    0 Not allowed!

    Default Re: Can the PRINT command halt program execution??

  8. Bob, this is the routine that I call when I want to take a reading from the DS1820 probe. This code was actually posted on here a couple of years ago and I have used it before without an issue but not in Proton 24 I think.

    Edit: I see that printing a string variable is the cause of the problem in my previous thread on an SD card too?!

    '-------------------------------------------------------------------
    DStemp:
    OWrite PORTB.5, 1, [$CC, $44] ' Start temperature conversion
    DelayMS 10
    While ORead PORTB.5, 4 = 0 :Wend 'Check for still busy convertin, wait here.


    OWrite PORTB.5, 1, [$CC, $BE] ' Read the Temperature


    ORead PORTB.5, 0, [DSTemperature.LowByte,DSTemperature.HighByte,temp, temp ,temp,temp,temp,temp]


    If DSTemperature.11 = 1 Then 'bit 11 to 15 if 1 it a negative number
    sign2 = "-" 'sign for two compliment number
    Else
    sign2 = "+" 'sign for
    EndIf


    ftemp = DSTemperature ' sign word var....
    ftemp = ftemp/16 'convert to float then divide by 16 to place decimal

    Return
    '-------------------------------------------------------------------
    Last edited by Klr650; 4th December 2018 at 19:25.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. serial input halting program execution
    By richardy in forum Proton Plus Compiler v3
    Replies: 1
    Last Post: 8th February 2010, 09:51
  2. Custom Print Command
    By wastrix in forum Proton Plus Compiler v3
    Replies: 4
    Last Post: 29th January 2010, 06:57
  3. how to program 18f4550 to print receipt
    By suzun in forum USB License key
    Replies: 1
    Last Post: 8th October 2009, 19:33
  4. Problems with the Print At y,x, command
    By kodiak in forum Proton Plus Compiler v3
    Replies: 27
    Last Post: 6th August 2007, 23:05

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts