How about String Variables?


Results 1 to 40 of 41

Threaded View

  1. #36
    Join Date
    Feb 2011
    Posts
    26


    Did you find this post helpful? Yes | No

    Default Re: How about String Variables?

    Thanks Charles for your subroutines.

    This is a snippet of code from a two temperature probe controller, chiller and alarm
    Alarm MIN and MAX
    Chiller MIN and MAX

    Crammed it into a 12f1822, should of used a 12f1840 for more space.

    Use gosub Print_Phrase: with zb pointing to the string.

    eg zb= Ofuzzy1 : gosub Print_Phrase

    will print out the copyright string:
    (C)2011 Ofuzzy1 All Rights Reserved - Not for Life Critical Use!


    Was cramped for space so phrases were pieced together.
    MIN Alarm would be pieced together
    Print_Alarm_Min:
    gosub Print_Alarm: gosub Print_Min:
    return
    '================================================= =====================================


    Code:
    ; Strings are stored in the EEPROM leaving more room for Programs
    ; The last char of the string has $80 added to it mark then end of the string.
    ;  this simplifies string maintenance.
    ; Strings are sent out via DEGUG for Async Serial - RS232
    ; Debug is smaller than serout and serout2
    
    ' print character defines
    CR              con 13
    LF              con 10
    VTAB            CON 11  ' VERTICAL TAB   = Clear Screen
    DEGREE          CON $DF
    Dash            con 45
    Space           con $20
    
    ' ---- The temps  they do all the grunt work with little or no pay :)
    AB          VAR BYTE    ' TEMP
    BB          VAR BYTE    ' TEMP
    xb          var byte    ' temp
    yb          var byte    ' temp
    zb          var byte    ' temp
    
    ' These are stored on the EEPROM Data area -- Leaves room for bigger programs
    '   *** Mark the end of the words with Char + 128
    ; @$10 starts the strings at location $10 [16] in the eeprom
    CharBump        con $80
    Ofuzzy1 data @$10,   "(C)2011 Ofuzzy1 All Rights Reserved - Not for Life Critical Use", "!" + CharBump
    W_Alarm  Data        "Alarm", "_" + CharBump     ; Alarm
    W_Min    Data        "Mi", "n" + CharBump        ; Min
    W_Max    Data        "Ma", "x" + CharBump        ; Max
    W_Normal Data        "Norma", "l" + CharBump
    W_Both_Probes Data   "Both Probe", "s" + CharBump
    W_Enter  Data        "& Ente", "r" + CharBump
    W_YNRQ   Data        "Y=Yes R=Redo N=No Q=Qui", "t" + CharBump
    
    '===========================================================================
    
    
    ; begin MAIN program code
    
    Gosub Print_Copyright
    End
    ;end MAIN program code
    
    ===========
    Print_Copyright:
    gosub CR_LF3 ': gosub CR_LF
    zb= Ofuzzy1 : gosub Print_Phrase
    gosub CR_LF3 ': gosub CR_LF
    return
    '======================================================================================
    Print_Phrase:   ' Call with zb = ROM_Memory_Location [byte] last char is >$80
    bb = 1          ' this could be re-written slicker but it works.
      Do until !BB '  = 0
        read zb, ab
        if ab > CharBump-1 then 
            ab = ab - CharBump
            bb = 0
        endif    
        debug ab
        zb= zb + 1
      loop
    return
    '======================================================================================
    CR_LF3:        ; 3 line feeds
    debug LF,cr
    CR_LF2:        ; 2 line feeds
    debug LF,cr
    CR_LF:
    debug CR,LF    ; 1 line feed
    return
    '======================================================================================
    Print_SP2:
    debug " "
    Print_SP:
    debug " "
    return
    '======================================================================================
    Print_LT:
    gosub Print_SP : gosub Print_lt1: gosub Print_SP 
    return
    '======================================================================================
    
    Print_LT1:
    debug "<": 
    return
    '======================================================================================
    
    Print_GT:
    gosub Print_SP : gosub Print_GT1: gosub Print_SP 
    return
    '======================================================================================
    
    Print_GT1:
    debug ">": 
    return
    '======================================================================================
    Last edited by ofuzzy1; - 12th January 2013 at 20:00.

Similar Threads

  1. How to convert HEX Value as formatted BIN String ?
    By Robson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 19th August 2007, 02:16
  2. Visual Basic 6 & Access 2000
    By Demon in forum Off Topic
    Replies: 33
    Last Post: - 7th September 2006, 04:39
  3. Variables not appearing in Watch Window MPLabv7.3
    By jd76duke in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 16th June 2006, 14:36
  4. String Parsing
    By eoasap in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th February 2006, 17:20
  5. Message String Table using Readcode
    By mytekcontrols in forum Code Examples
    Replies: 2
    Last Post: - 10th July 2005, 23:17

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

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