don't understand error"closing patrenthasis misssing despite there is one"

Started by basiclover, May 13, 2022, 10:49 AM

Previous topic - Next topic

basiclover

error despite there is closing patenthesis on last line 50
''****************************************************************
'*  Name    : 16F877A TEST.BAS                  *
'*  Author  : basiclover                                        *
'*  Notice  : Copyright (c) 2022 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 5/13/2022                                         *
'*  Version : 1                                                *
'*  Note    :                                                   *                     
'*          :                                                   *
'*                                                              *
'****************************************************************

;-------------------------------------------------------------------------------
;**** 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 ****
;-------------------------------------------------------------------------------
    'Declare Xtal = 20                            ' Tell the compiler what speed the device will be operating at
    Declare Float_Display_Type = Fast           ' Use the faster, more accurate, but larger, floating point display library routine
'
' Setup the alphanumeric LCD
    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 = 4
    Declare LCD_DataUs 75     'LCD time to wait beween data sent(microsec)for some older 16x2 44780 compatible displays (default = 50)

'--------------------------------------------------------------------------------------------------------------
'
'
    Device = 16F877                             ' Tell the compiler what device is being compiled for
    Declare Xtal = 20                           

'
' Create some variables
    Dim MyString As Byte
    Dim MyVariable As Byte                       
    Dim MyValue As Byte               
   
    Cls
 MAIN:
    MyString= "8"
    MyVariable=Val(MyString,Dec)

top204

The error message for the fact that the parser cannot see the closing parenthasis is over-riding the error that the Val function only works with a String or Byte Array.

Remove the parenthasis and the true error message will appear: "*** MyString is an unsupported variable type/value at this position! ***".

I'll get into the parser and move the "parenthasis" error message down a notch in the error TList queue, so it is over-riden by the original error it sees.

basiclover

#2
thanks
what I want to do is convert the number output value of Inkey function to an integer as it seems to be an Ascii value

RGV250

Hi,
If I understand correctly all you need to do is subtract 48 from the value.

Looking at the manual it returns a value from a lookup so it will not be ascii.

Bob

top204

The Inkey command returns a value from 0 to 16, so the best method to convert it is a lookup table.

See Converting numeric keypad entries into a value, in the forum's code examples posts. It shows a method of converting the matrix value returnd from Inkey, into ASCII values. And my posts in this thread: https://protoncompiler.com/index.php/topic,943.0.html