Announcement

Collapse
No announcement yet.

Syntax errors, why?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Syntax errors, why?

    Dear support

    I have written een console program for control the 8243 expander ports. When I compile my program it doesn't give me compile errors.
    There is no example how I can right use the functions HI() en LO()

    Error report:
    =========

    PowerBASIC Console Compiler
    PB/CC Version 5.00
    Copyright (c) 1998-2008 PowerBasic Inc.
    Venice, Florida USA
    All Rights Reserved

    Error 477 in E:\PROGRA~1\PBCC50\Samples\PCPOOR~1\WinXP\PARALL~1\8243_P~2\2PortsExpander32Bits.bas(128:034): Syntax error
    Line 128: Instellen(0, LO(LONG,n)) MOD 16) 'P0: bits 0...3
    ==============================
    Compile failed at 9:25:17 on 26/09/2008

    Code:
    'Problem 1
    =======
    
    Instellen(0, LO(LONG,n)) MOD 16)                'P0: bits 0...3              
    
    'Problem 2
    =======
    
    writeLn(n, ' ' , value);  into PBCC code
    
    DIM value   AS BYTE           
    value = Inlezen(4) + 16 * Inlezen(5) + 256 * Inlezen(6) + 4096 * Inlezen(7)
    STDOUT " " & HEX$(n) & HEX$(value) & $CR & $LF
    The Whole code in attachtment file for look the full code that you can analyse what I have wrong

    Kind regards
    Stephane
    [/CODE]

    Use the Evaluation version of the NtPort.dll library
    http://www.zealsoftstudio.com/ntport/

    Attachment : My halfworked application runs under console 32-bit
    Attached Files
    Last edited by Stephane Fonteyne; 26 Sep 2008, 05:14 AM. Reason: New file with corrected errors

  • #2
    When I compile my program it doesn't give me compile errors.
    --- That's good, isn't it ?

    Error 477 in E:\PROGRA~1\PBCC50\Samples\PCPOOR~1\WinXP\PARALL~1\8243_P~2\2PortsExpander32Bits.bas(128:034): Syntax error
    --- That's not good, isn't it ...


    Missing parenthesis:
    Code:
     Instellen(0, LO(LONG,n)) MOD 16)
    Notice: 2 times "(" and 3 times ")"

    So probably something like this should work:
    Code:
     Instellen[B]([/B](0, LO(LONG,n)) MOD 16)
    Kind regards
    Last edited by Eddy Van Esch; 26 Sep 2008, 02:53 AM.
    Eddy

    Comment


    • #3
      No it have the same errors !

      Eddy

      Here is my right corrected code:
      ========================

      Code:
      GLOBAL PortNumber AS LONG, DataBits AS BYTE
      FUNCTION PBMAIN () AS LONG
          
          DIM n       AS LONG
          DIM value   AS BYTE
      
          FOR n = 0 TO 65535
                      
              Instellen((0, LO(LONG,n)) MOD 16)                'P0: bits 0...3
              Instellen((1, LO(LONG,n)) \ 16)                  'P1: bits 1...7
              Instellen((2, HI(LONG,n)) MOD 16)                'P2: bits 8...11
              Instellen((3, HI(LONG,n)) \ 16)                  'P3: bits 12..15
      
              value = Inlezen(4) + 16 * Inlezen(5) + 256 * Inlezen(6) + 4096 *  Inlezen(7)
              STDOUT " " & HEX$(n) & HEX$(value) & $CR & $LF
              'WriteLn(n,' ',Inlezen(4) + 16 * Inlezen(5) + 256 * Inlezen(6) + 4096 * Inlezen(7)
          NEXT n
      
      END FUNCTION
      
      SUB Instellen(BYREF PortNr AS BYTE, BYREF DataWoord AS BYTE)
          LOCAL CS AS BYTE
      
          IF (PortNr \ 4) = 0 THEN CS = 4                                 'D1 = CS1 = 0 2^2
          IF (PortNr \ 4) = 1 THEN CS = 2                                 'D2 = CS2 = 0 2^1
      
          OutPort ((LPT1), CS + 1)                                        'D0 = CONTROL = 1
          OutPort ((LPT1 + 2), ((PortNr AND &h03) + &h04) XOR &h0B))      'Stuurcommando
          OutPort ((LPT1), CS)                                            'D0 = CONTROL = 0
          OutPort ((LPT1 + 2), DataWoord XOR &h0B                         'Datawoord
          OutPort ((LPT1), CS + 1)                                        'D0 = CONTROL = 1
          OutPort ((LPT1), &h06 + 1)                                      'CS1 = 1, CS2 = 1
      END SUB
      
      Error report:
      =========
      
      PowerBASIC Console Compiler
      PB/CC   Version 5.00 
      Copyright (c) 1998-2008 PowerBasic Inc.
      Venice, Florida USA
      All Rights Reserved
      
      Error 414 in E:\PROGRA~1\PBCC50\Samples\PCPOOR~1\WinXP\PARALL~1\8243_P~2\2PortsExpander32Bits.bas(127:021):  ")" expected
      Line 127:         Instellen((0, LO(LONG,n)) MOD 16)                'P0: bits 0...3
      ==============================
      Compile failed at 10:15:40 on 26/09/2008
      
      Can somebody help me what I do wrong ?

      Comment


      • #4
        What is the use of using LO(LONG, n) and HI(LONG, n) if n is already a LONG variable ??

        Code:
            DIM n       AS LONG
                Instellen((0, LO(LONG,n)) MOD 16)
                Instellen((2, HI(LONG,n))
        Eddy

        Comment


        • #5
          Code:
          Instellen((0, LO(LONG,n)) MOD 16)
          perhaps should be something like this:
          Code:
          Instellen(0, n MOD 16)
          etc...
          Eddy

          Comment


          • #6
            Originally posted by Eddy Van Esch View Post
            Code:
            Instellen((0, LO(LONG,n)) MOD 16)
            perhaps should be something like this:
            Code:
            Instellen(0, n MOD 16)
            etc...
            or maybe you mean LO(INTEGER,n)? as the book says,

            LO function
            Purpose
            Extract the least significant (low-order) portion of an value.

            Syntax
            result = LO(type, value)

            Remarks
            The value returned by LO is unsigned if type is BYTE, WORD, or DWORD, and signed if type is INTEGER or LONG. value may be up to twice the size of the data type specified by type. In the following example, n may be up to a 16-bit value (twice the size of a BYTE):

            b = LO(BYTE,n)

            Restrictions
            LO replaces LOBYT, LOWRD, and LOINT. Note that those functions may not be supported in future versions of PowerBASIC, so update your code to use the new syntax.

            See also
            HI, MAK

            Comment


            • #7
              Thanks developers

              My code works now

              Comment

              Working...
              X