• PicŪ Basic


  • BubbleSort

    A library module for use withLibrary Manager by JohnGB. This module has been written by Tim Box (Tim on PDS forum). The library module is offered on an as-is basis with no warranty as to its effectiveness, operation or reliability. Users use it at their own risk.

    Adds a new command called BubbleSort

    Syntax

    BubbleSort Array, Elements, Direction

    Overview

    Performs a bubble sort on N number of elements on a byte array in either direction.

    Operators

    Array – any Byte array

    Elements - a constant, or byte variable indicating the number of elements within the array to sort

    Direction - a constant, or byte variable indicating the direction of sorting 0 or 1. Any number > 0 will be taken as 1. 1 = high numbers first, 0 = low numbers first

    Code:
    Include "proton_4.inc""   
    
        Dim myarray[10] As Byte
        Dim index As Byte
    
        For index = 0 To 9
            myarray[index] = index
            HRSOut Dec myarray[index],", "
        Next
    
        HRSOut 13,10 
    
        index = 1 
    
        BubbleSort myarray, 10, index
    
        For index = 0 To 9
            HRSOut Dec myarray[index],", "
        Next
    
        HRSOut 13,10
    
        index = 10
    
        BubbleSort myarray, index, 0 
    
        For index = 0 To 9
            HRSOut Dec myarray[index],", "
        Next
    
        HRSOut 13,10
    
        Stop
    The above example code will fill an array with the values from 0 to 9 and send then sort the array first down then up.


    Download module

    Download: Bubble Sort
  • Recent Activity

    kbaykar-24295

    Fault in bit wise comparisons on release 3.6.1.2.

    Thread Starter: kbaykar

    Hi Les, I just downloaded the release 3.6.1.2 today and seeing that it supports 18F47K40. I am trying to port my code from 18F4685 to 18F47K40. ...

    kbaykar Today, 17:26 Go to last post
    John Drew-26

    About Define directive...

    Thread Starter: SELCUK

    Hi Les, Thank you for new version of Proton Plus. For both Compiler version 3.6.1.1 and 3.6.1.2 If I define $DEFINE FF $0C ;// Form...

    John Drew Today, 02:10 Go to last post
    towlerg-21522

    Num_Byte on 18F26K42

    Thread Starter: towlerg

    I'm using a macro that was created by the generator Dump Macro P1 #if (Prm_Count > 1) #error "Dump - Too many parameters" #else ...

    towlerg Today, 19:20 Go to last post
    normnet-324

    Update path?

    Thread Starter: normnet

    I am currently running Proton v3.6.0.2 and would like to update to the latest version. Can i install the latest Update v3.6.1.2 on top of my...

    normnet Today, 14:41 Go to last post