Code error


Today 06:42
Forum: Proton Plus Compiler v3
Starter: shantanu@india
Views: 0
Replies: 10
Yesterday 20:20
Forum: Absolute Beginners Section
Starter: moonshadow
Views: 0
Replies: 0
+ Reply to Thread
Results 1 to 3 of 3

Thread: Code error3 days old

  1. #1
    Inactive member ngilmore's Avatar
    Join Date
    Mar 2019
    Posts
    1
    Thumbs Up
    Received: 1
    Given: 0
    Total Downloaded
    76.28 MB

    1 Not allowed!

    Default Code error

    I made some changes to some very old code and had a problem compiling it as I have the following (which I got from sample code Bargrahp.bas)
    Fullbars = (Barval Min 48) /3
    The problem seems to be with the Min, I checked the user manual and can't find any reference to this can anyone please help.

    Fullbars and Barval are just my variables, this code compiled years ago ok.

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    Prolific Poster rcurl's Avatar
    Join Date
    Mar 2002
    Posts
    1,806
    Thumbs Up
    Received: 36
    Given: 53
    Total Downloaded
    1.76 GB

    1 Not allowed!

    Default Re: Code error

    Yep- The MIN function went away a while back. Here's the way I re-did my bar graph code:
    Code:
    Dim A2D_VAL As Word   ' The value from the A/D converter
    Dim BAR_VAL As Word   ' Value to be graphed.
    Dim BARS As  Byte      ' Number of full ||| bars to draw.
    Dim BALANCE As  Byte    ' Balance left after all |||s are drawn.
    Dim BALF As Byte        ' Is a 'Balance' character needed? (1=yes, 0=no).
            
    
    
    BAR_VAL = A2D_VAL / BAR_CAL
    BAR_VAL = A2D_VAL / BAR_CAL
    If BAR_VAL < MAXBAR Then     ' One full bar for each 3 graph units.
       BARS = BAR_VAL /3
       BALANCE = BAR_VAL //3
    Else
       BARS = BAR_VAL /3
       BALANCE = MAXBAR //3
    EndIf
       If BALANCE < 1 Then        ' Balance is the remainder after a division by 3.
       BALF = BALANCE
    Else
       BALF = 1
    EndIf
    Print At 1,1,Rep FULLBAR\BARS,Rep (BALANCE + BASEBAR)\BALF,Rep " " \B_WDTH - (BARS + BALF)
    I hope that helps.

    -Rick
    Last edited by rcurl; 16th May 2019 at 13:07.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Fanatical Contributor Les's Avatar
    Join Date
    Feb 2002
    Posts
    3,193
    Thumbs Up
    Received: 367
    Given: 132
    Total Downloaded
    1.56 GB

    0 Not allowed!

    Default Re: Code error

    The Min and Max functions were removed from the compiler many years ago, because they were interfering internally with it, and it was more robust to remove them than to try and tamper too much with the parser. I'll take a look at them later, but they will be a function, rather than an operator.

    However, they can easily be re-created with a pair of procedures:

    Code:
        Dim Bytein1 As Byte
        Dim Bytein2 As Byte
        Dim Byteout As Byte
    
    '-------------------------------------------------------------
    ' Find the maximum of 2 values
    ' Input     : pValue1 holds the first value to compare
    '           : pValue2 holds the second value to compare 
    ' Output    : Returns the maximum of both values
    ' Notes     : None
    '   
    Proc Max16(pValue1 As Word, pValue2 As Word), Word
        Result = pValue2                ' Default to returning pValue2 as the result
        If pValue1 > pValue2 Then       ' Is pValue1 greater than pValue2?
            Result = pValue1            ' Yes. So return pValue1 as the result
        EndIf
    EndProc
    
    '-------------------------------------------------------------
    ' Find the minimum of 2 values
    ' Input     : pValue1 holds the first value to compare
    '           : pValue2 holds the second value to compare 
    ' Output    : Returns the minimum of both values
    ' Notes     : None
    ' 
    Proc Min16(pValue1 As Word, pValue2 As Word), Word
        Result = pValue2                ' Default to returning pValue2 as the result
        If pValue1 < pValue2 Then       ' Is pValue1 less than pValue2?
            Result = pValue1            ' Yes. So return pValue1 as the result
        EndIf
    EndProc
    
    '-------------------------------------------------------------
    '
    ' Demo of the Min16 procedure
    '
        Bytein1 = 5
        For Bytein2 = 0 To 10
            Byteout = Min16(Bytein1, Bytein2)
            HRSOutLn "Bytein1 = ", Dec Bytein1, " : Bytein2 = ", Dec Bytein2
            HRSOutLn Dec Byteout, " Is the lowest"
            DelayMS 100 
        Next
    ' 
    ' Demo of the Max16 procedure
    '
        Bytein1 =  5 
        For Bytein2 = 0 To 10 
            Byteout = Max16(Bytein1, Bytein2)
            HRSOutLn "Bytein1 = ", Dec Bytein1, " : Bytein2 = ", Dec Bytein2
            HRSOutLn Dec Byteout, " Is the greater"
            DelayMS 100 
        Next
    In order to make the procedures also do Min and Max with signed variables, change the parameter types to Sword, and the returns to Sword, and, maybe call them MinS16 and MaxS16. For 32-bit operation, create 2 procedures that use Dword or SDword as the parameter types and return type, and the names Min32 and Max32. etc... The same for Floating Point... Change parameter types and the name. I'm looking into overloading with procedures, but it is a time off just yet because the underlying code is quite complex to create from scratch.

    Procedures make a lot of the compiler's built in functions more flexible because they can be recreated in the BASIC listing, and altered to suit better, instead of more generic. Also remember, a procedure will not be used in the code if it is not called in the BASIC listing, so libraries of new functions can also be created.
    Last edited by Les; 17th May 2019 at 12:47.
    For more example programs for Proton and Proton24 or updates, please visit: Proton WIKI or Proton Files

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Error code - not seen before.
    By iwmoz in forum Proton Plus Compiler v3
    Replies: 15
    Last Post: 14th January 2015, 15:18
  2. SHOut error my code or proton anomoly?
    By POLL in forum Proton Plus Compiler v3
    Replies: 14
    Last Post: 18th May 2014, 18:51
  3. error code
    By ngilmore in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 15th December 2012, 00:06
  4. BCH Error Correction Code
    By Peter Truman in forum Proton Plus Compiler v3
    Replies: 6
    Last Post: 22nd July 2010, 07:49

Members who have read this thread : 49

Actions :  (Set Date)

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