Main:
InBuff$ = "Hello word!"
IF InBuff$ = "Hello word!" THEN GOTO Next
Next:
Output from gcbasic:
;Program compiled by Great Cow BASIC (0.9 10/2/2007)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F876A, r=DEC
#include <P16F876A.inc>
__CONFIG _XT_OSC & _WDT_OFF & _LVP_OFF
;Start of the main program
MAIN
bsf STATUS, IRP
movlw 218
movwf FSR
clrf StringPointer
SysReadString1
call StringLookup1
movwf INDF
incf StringPointer, F
incf FSR, F
movf StringPointer, W
sublw 12
btfss STATUS, Z
goto SysReadString1
movf %STRING2%,W
subwf INBUFF(),W
btfsc STATUS, Z
goto NEXT
NEXT
BASPROGRAMEND
sleep
goto $
;********************************************************************************
;Subroutines included in program
;********************************************************************************
Test program:
#chip 16f876a, 4
#osc XT
dim InBuff as string
Main:
InBuff$ = "Hello word!"
IF InBuff$ = "Hello word!" THEN GOTO Next
Next:
Output from gcbasic:
;Program compiled by Great Cow BASIC (0.9 10/2/2007)
;Need help? See the GCBASIC forums at http://sourceforge.net/forum/?group_id=169286,
;check the documentation or email hconsidine@bigpond.com.
;********************************************************************************
;Set up the assembler options (Chip type, clock source, other bits and pieces)
LIST p=16F876A, r=DEC
#include <P16F876A.inc>
__CONFIG _XT_OSC & _WDT_OFF & _LVP_OFF
;********************************************************************************
;Set aside memory locations for variables
%STRING2% equ 32
DataPointer equ 33
INBUFF equ 34
INBUFF() equ 35
StringPointer equ 36
;********************************************************************************
;Jump to initialisation code when PIC is reset
ORG 0
call INITSYS
goto SystemInitialise
;********************************************************************************
;Interrupt vector
ORG 4
retfie
;********************************************************************************
;Various initialisation routines, automatically called by GCBASIC
SystemInitialise
;********************************************************************************
;Start of the main program
MAIN
bsf STATUS, IRP
movlw 218
movwf FSR
clrf StringPointer
SysReadString1
call StringLookup1
movwf INDF
incf StringPointer, F
incf FSR, F
movf StringPointer, W
sublw 12
btfss STATUS, Z
goto SysReadString1
movf %STRING2%,W
subwf INBUFF(),W
btfsc STATUS, Z
goto NEXT
NEXT
BASPROGRAMEND
sleep
goto $
;********************************************************************************
; String Lookup Tables
StringLookup1
bcf STATUS, C
movf StringPointer, W
addlw 1
addlw low StringTable1
movwf DataPointer
movlw high StringTable1
btfsc STATUS, C
addlw 1
movwf PCLATH
movf DataPointer, W
StringTable1
movwf PCL
retlw 11
retlw 72 ;H
retlw 101 ;e
retlw 108 ;l
retlw 108 ;l
retlw 111 ;o
retlw 32 ;
retlw 119 ;w
retlw 111 ;o
retlw 114 ;r
retlw 100 ;d
retlw 33 ;!
return
StringLookup2
bcf STATUS, C
movf StringPointer, W
addlw 1
addlw low StringTable2
movwf DataPointer
movlw high StringTable2
btfsc STATUS, C
addlw 1
movwf PCLATH
movf DataPointer, W
StringTable2
movwf PCL
retlw 11
retlw 72 ;H
retlw 101 ;e
retlw 108 ;l
retlw 108 ;l
retlw 111 ;o
retlw 32 ;
retlw 119 ;w
retlw 111 ;o
retlw 114 ;r
retlw 100 ;d
retlw 33 ;!
return
;********************************************************************************
;Subroutines included in program
;********************************************************************************
INITSYS
clrf PORTA
clrf PORTB
clrf PORTC
movlw 7
banksel CMCON
movwf CMCON
banksel ADCON0
bcf ADCON0,ADON
banksel ADCON1
bcf ADCON1,ADFM
bcf ADCON1,PCFG3
bsf ADCON1,PCFG2
bsf ADCON1,PCFG1
bcf ADCON1,PCFG0
banksel STATUS
return
;********************************************************************************
END
Output from gpasm:
Assembling program ...
Assembly failed due to the following errors:
compiled.asm:15:Error [103] syntax error
compiled.asm:81:Error [103] syntax error
compiled.asm:83:Error [113] Symbol not previously defined (SysCompEqual).
compiled.asm:89:Error [103] syntax error
The current version of GCBASIC (0.9.3.0) does not support any operations on strings, other than copying them into arrays.
However, I'm improving this in the next version. Currently I've implemented string copy, join and comparison. These are now in http://gcbasic.sourceforge.net/newfiles/update.zip
Here is a program that I've used to test the routines:
#include "mytest.h"
Dim TestString$ as string
Dim OtherString$ as string
TestString$ = "Hello"
OtherString$ = TestString$ + " Lemurs"
Print TestString$
Locate 1, 0
Print OtherString$
(mytest.h is a file that contains the #chip line and the LCD #defines for my test circuit - I use it to save myself some typing.)
The program you posted should also work now.