Don't understand compiling error @ line 53 (Print At ) "variable Dec2 not found"

Started by basiclover, Jan 14, 2022, 12:51 PM

Previous topic - Next topic

basiclover

I don't understand compiling error at line 53 "variable Dec2 not found""

'****************************************************************
'*  Name    : display floating point components.BAS             *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 1/14/2022                                          *
'*  Version : 1.0                                               *
'*  Notes   :                                                   *
'*          :                                                   *
'****************************************************************
;-------------------------------------------------------------------------------
;**** Added by Fuse Configurator ****
; Use the Fuse Configurator plug-in to change these settings

Device = 16F877A

Config FOSC_HS, WDTE_OFF, PWRTE_OFF, BOREN_ON, LVP_OFF, CPD_OFF, WRT_OFF, DEBUG_OFF, CP_OFF

;**** End of Fuse Configurator Settings ****
;-------------------------------------------------------------------------------

 ' LCD defs
    Declare LCD_Type = 0       'HITACHI HD44780 controller
    Declare LCD_DTPin PORTB.4  '4 pin config, data on 4 top pins(PortB4 to B7) of port B
    Declare LCD_RSPin = PORTB.3
    Declare LCD_ENPin = PORTB.2
    Declare LCD_Lines = 2
    Declare LCD_DataUs 75     'LCD time to wait beween data sent(microsec)for some older 16x2 44780 compatible displays (default = 50)
   
    Declare Xtal = 20
   
    Dim exponent As Byte
    Dim mantissa As Byte     
    Dim PBP_AARGHHH As Byte
    Dim PBP_AARGHH As Byte
    mantissa= PBP_AARGHH
    exponent= PBP_AARGHHH
    Dim Flt1 As Float
    Dim MyFloat As Float
    Flt1=3.145
    MyFloat=flt1+2
    ADCON1 = 6 ' Set all ports A to digital
    TRISA=%00000000 'set all portA to output
    TRISB=%00000011 'RB0 RB1=inputs, other=outputs
    TRISC=%00000100 'RC2 =input
    TRISD=%00000000 'RCD =ouputs
   
    Cls
    GoTo main
main:
    Print At 1.1,exponent
    Print At 2.1,mantissa
 53 Print At 2.10,Dec2 Flt1
    GoTo main
    End

trastikata

Replace the point with a comma in those lines:

    Print At 1.1,exponent
    Print At 2.1,mantissa
    Print At 2.10,Dec2 Flt1

basiclover


top204

When the compiler's parser saw the Floating Point value "2.10", it rounded it down to 2, and looked for the X position parameter, but it saw the text "Dec2", and that is not a variable, so it gave the correct error!

With the two previous Print At commands, it used the rounded down values of "1.1" and "2.1" as the line parameters, and variables "exponent" and "mantissa" as the X position variables, but there was nothing to print after them, so it carried on to the next line. No error was needed because they were valid.

There is a big difference between a comma and a decimal point to the parser. :-)