File Compare 3

Post Reply
User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

File Compare 3

Post by GeorgeMcGinn »

NOTE: File on Dropbox updated at 05:18am EDT. Removed comment that kept the toolbar from being shown. Image updated as well. George.

Version 3 of the original File Comparison program written by Ricardo (Rbytes) is ready for download.

All the files and folders, including text files on how to use and run compares can be found: Dropbox Link: https://www.dropbox.com/sh/39vwwttaxwlx ... lgOYa?dl=0

Originally this program was designed by Ricardo (Rbytes) to compare two files line-by-line and note any differences for checking if supposedly identical files has been modified or may have been corrupted so you can restore it based on a previous version used to compare. Now it does that and more. With some standization and powerful options, you will be able to compare program or data lines with options such as ignoring: indents, blank/null lines, and extra/excess spaces.

Also, some standardization has been instituted, more for future releases where knowing which is the new and older versions will be critical to the compare. So, for now:

File1$ is now the newest version of the source code or data file
File2$ is now an older version of the source code or data file

ABOUT VERSION 3
Version 3 is a major release that not only fixes some issues found in the first release, it adds four processing switches, furthering the power and accuracy of the compare by allowing the user to set conditions that in the past would have either produced a false 'MATCH' or more commonly a false 'NO MATCH'. These processing switches makes this program close to rivaling those found on Mainframe systems and in the best PC or MAC applications (See post and change log for v3.0 for the change details on how the switches process the source or data).

CHANGES MADE (CHANGE LOG) to FILE COMPARISON
Briefly, the changes made are:
v3.0 Updates (George McGinn, September, 2017)
  • Fixed premature end when one file reaches EOF and the other file still has unprocessed lines. These lines will now be displayed as "No Match" and appear on the report.

    • Added a switch to allow the user to SHOW or HIDE all lines that matches.

    • Added a switch to process or ignore BLANK LINES in the compare. In Data, the blank line may mean missing data, where in source code, it is used to make a program more readable and not a valid compare test (more of a programmer's preference).

    • Added a switch to allow the inclusion or exclusion of INDENTED lines in the compare process. Like BLANK LINES, indenting is mostly a personal preference in writing source code.

    • Added a switch to allow the compare of lines without spaces (Ignore Empty Spaces). Again, a programmer preference, this will resolve code that is the same, but one programmer may like to line up = signs or other formatting. However, if you set this switch to "Y", you must also set "Ignore Blank Lines" to "Y", otherwise the mismatching due to extra blank/null lines means this switch has no effect. Both must be on to get the right line-up and the proper matches for format issues. Indents can be either a "Y" or "N", as removing all spaces negates the check, making it useless as any indents will be removed when all spaces are removed.
To Learn how to use the new features in Version 3, read: File Compare – Readme.txt

Please keep the Data and Images in the folders for now. When running compares, you can run any file in any directory by supplying the proper directory path. The ELIZA programs are just to be used with the document that explains how the File Compare works and has all of the test conditions in them. Once done, you may delete the ELIZA programs.
Attachments
Example of File Compare GUI
Example of File Compare GUI
IMG_1901.PNG (936.68 KiB) Viewed 2259 times
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

User avatar
GeorgeMcGinn
Posts: 435
Joined: Sat Sep 10, 2016 6:37 am
My devices: IPad Pro 10.5in
IMac
Linux i386
Windows 7 & 10
Location: Venice, FL
Flag: United States of America
Contact:

Re: File Compare 3 - Components

Post by GeorgeMcGinn »

Hello,

In case you do not have access to Dropbox, here are the individual components to run the File Compare v3.0. Here are the directory structure:

File Compare v3.0.sb
File Compare – Readme.txt
>>> Data/ELIZA.sb
>>>Data/ELIZA Copy.sb
>>>Data/ELIZA Old.sb
>>>Images/scope.jpg
>>>Documentation/File Compare – Instructions.txt
>>>Documentation/File Compare – Showing Its Features.txt




Main Source Code: File Compare v3.0.sb

Code: Select all

/*
Program: File Compare v3.0
Written by Ricardobytes – October 2016 (As File Comparison v1.0)
Modified by George McGinn – December, 2016 (As File Comparison v1.5 and 2.0)
Modified by George McGinn - November, 2017 (File Compare v3.0)
--------------------------------------------------------------------------------------------------
Version 3 is a major release, as it not only fixes some issues found in the first release, it adds four processing switches, furthering the accuracy of the compare by setting the conditions that would provide you with either a false "MATCH" or more commonly a false "NO MATCH." These processing switches makes this program one to two steps from rivaling that found on Mainframe systems and in the best PC or MAC applications (See post and change log for v3.0 for the changes included).

NOTE: This program has been released with the Help Panel System pulled at it was interfering with the screen and even some processing. I will have it all worked out for version 3.5. In the meantime, check below and the post's text for the Help and Instructions on how this new File Compare works. The following is the Help Panel Information:

FILE COMPARE FEATURES:

END OF FILE ISSUE
The original program when it reached and EOF on either file terminated without processing the remaining records. That was carried over into releases 1.5 and 2.0. These lines are still part of the compare process, and should show up as either additions to one file, or deletions on other. This was the minor bug that may have been left like that on purpose since the original code was to detect files that were corrupted. But based on the changes planned for the future, these lines must be displayed as 'NO MATCH' and will now appear on the report.

Here are all the run options and what they do, and in certain cases, how they interact with each other. Currently the default is set to "IGNORE ALL SPACES" which runs all the options, providing the most accurate compare of two source code files. If running a compare against two data files, some or none of the switches may be needed, depending on the data.

SHOW/HIDE MATCHES (Default is HIDE or “H”)
A switch has been added to allow you to either show or hide the lines that ‘MATCH’. (S=Show, H=Hide). This allows you to see the whole program, including the lines that are common in each program. Regardless of the other switches, this works independently from all the others.The default value is H, which hides the lines that MATCH.

IGNORE ALL SPACES (Default is IGNORE or “Y”)
This is a special switch. IGNORE ALL SPACES (Y=Ignore, N=leave line as it) has an effect on all BLANK/NULL LINES and INDENTATION switches. Selecting this switch not only compresses the line to remove all spaces, but it also executes the BLANK/NULL and INDENTATION, regardless of their setting. Spaces, whether it is in the line, intending or putting in a space or null line are preferences used by programmers to either make the code readable, or used to separate functions/routines, align items in a statement to match multiple lines, or to show high-level code from low-level, or code that executes under commands such as IF/THEN, DO/UNTIL, WHILE/WEND, or within Functions and Subroutines.  Each programmer has their own preferences, where some do not add anything extra to the other extreme by adding 2, 3, 4 or more spaces. (The line “A=A+1” is the same as “A = A+1” or “A = A + 1”). When spaces removed, they are a match.  Without the ability to remove extra spaces, this line will be flagged as 'NO MATCH'. No matter how many spaces used to format lines of code, this switch will reduce the line in both files to just the code, which if it is the same, then it is considered a MATCH. 

BLANK/NULL LINES (Default is IGNORE or “N”)
This switch allows the user to ignore BLANK or NULL lines in the compare process. (Y=Bypass BLANK/NULLS, N=Include BLANK/NULL lines in compare). Especially in program source code, programmers will insert blank or null lines based on their coding preference. This creates a problem when doing a line by line compare. Now you have the ability to tell the compare to not consider blank and null lines in the compare and the program will just bypass these in both files. With these lines considered, if another programmer likes 2 lines between, say, functions and sub-routines, and the other likes 1 or none, the new program will be out of sync and all lines after the second blank/null will be considered a 'NO MATCH'.

IGNORE/ALLOW INDENTATION (Default is IGNORE or “N”)
Indentation is another programmer preference when writing source code. (Y=Ignore INDENTATION, N=Allow INDENTATION to be considered). Some programmers use indentation to show code that runs subordinate to, say, an IF statement or DO/WHILE loop. So you will see indentations of 2, 3, 4 or more spaces, others none. There may be a mixture or inconsistent indentation. This option allows you to ignore all indented spaces before comparing the two lines. Without this, the compared lines with different indentations will be flagged as 'NO MATCH' even though they may be the same.

HELP BUTTON
The HELP button has been deactivated and code removed as all my test cases were failing in some way or another, or the panel didn’t display correctly, or it executed the compare after closing out. If even froze the program, displayed the GUI missing all the input boxes, or leaving artifacts behind. This will be put in in Version 3.5 along with other suggestions made that are minor enough to implement. The reason is in the next section.

--------------------------------------------------------------------------------------------------

Program Modifications:
----------------------

v3.0 Updates (George McGinn, September, 2017)
	– Fixed premature end when one file reaches EOF and the other file still has unprocessed lines. 
     These lines will now be displayed as "No Match" and appear on the report.
	– Added a switch to allow the user to SHOW or HIDE all lines that matches.
	– Added a switch to process or ignore BLANK LINES in the compare. In Data, the blank 
	  line may mean missing data, where in source code, it is used to make a program more 
	  readable and not a valid compare test (more of a programmer's preference).
	– Added a switch to allow the inclusion or exclusion of INDENTED lines in the compare 
	  process. Like BLANK LINES, indenting is mostly a personal preference in writing source 
	  code.
	– Added a switch to allow the compare of lines without spaces (Ignore Empty Spaces). 
	  Again, a programmer preference, this will resolve code that is the same, but one 
	  programmer may like to line up = signs or other formatting. However, if you set this 
	  switch to "Y", you must also set "Ignore Blank Lines" to "Y", otherwise the mismatching 
	  due to extra blank/null lines means this switch has no effect. Both must be on to get 
	  the right line-up and the proper matches for format issues. Indents can be either a 
	  "Y" or "N", as removing all spaces negates the check, making it useless as any indents 
	  will be removed when all spaces are removed.

v2.0 Updates (George McGinn, December 2016) 
	– Converted entire program to Graphic GUI, adding in color and the DrawInfoBar. 
	– Made changes to prevent abnormal terminations and allows the user
     to run program as many times with as many different files without shutting down
     the program to change files. Version 1.5 did not run uninterrupted.

v1.5 Updates (George McGinn, December, 2016)
	- Added File Comparison to a modified Screen Input program that was made fully
  	  graphical. This was a no-frills update, where a white background/black text
	  user interface was literally merged with File Comparison to make a GUI for it.

v1.0 Original Program (Ricardo - Rbytes, October, 2016)
   – Written to compare two files line-by-line and note any differences for checking if 
     supposedly identical files has been modified or corrupted
---------------------------------------------------------------------------------------------------------
                       
*/


SBInit:
'---------------------------------------------------------------------------------
'*** Initialization of program's system settings, variables, iPad/iPhone settings,
'*** screen sizes, orientation, and other settings: NOTE: Application variables
'*** will appear elewhere.
'
GRAPHICS
OPTION ANGLE DEGREES
OPTION BASE 1
SET TOOLBAR OFF
OPTION KEYBOARD ON
GET SCREEN SIZE sw,sh

GRAPHICS CLEAR .6,.6,.6

SET ORIENTATION LANDSCAPE
GET SCREEN SIZE W,H

dev$=DEVICE_TYPE$()
iostest=0                  ' set to 1 to test other iOS devices on iPad
IF iostest THEN
   dev$=""
   W=667!H=375             ' to test iPhone 6
ENDIF


'*** Needed to provide compatability with other modules (from other programmers)
sw=W!sh=H                         '*** sw,sh is Screen Width, Height
'*** scale factor for other iOS devices
ratw=W/1024!rath=H/768!vadj=0!hadj=20!cr$=CHR$(10)
.rw=ratw!.rh=rath

IF dev$="iPad" THEN
   hm=4                    ' horizontal margin
   vm=100                  ' vertical margin
   imy=-30
   heightshift=0!titleshift=0!tvshift=0!bvshift=30
ELSE
   hm=4*ratw               ' horizontal margin
   vm=130*rath-20          ' vertical margin
   imy=-60
   heightshift=20!titleshift=25!tvshift=10!bvshift=10
ENDIF


SBMain:
'---------------------------------------------------------------------------------
'*** Main Program Logic
'
    calc=TIME()!TRUE=1!FALSE=0!BUTTON.SELECTED=FALSE
    SPACES$=".                                                                                         "
    SPACE$= " "!NULL$=""
    app$="File Compare v3.0"

'*** Set's up the buttons
    BUTTON "comp" TEXT "COMPARE" AT 730+vadj,275+hadj SIZE 100,30
    BUTTON "quit" TEXT "QUIT"    AT 835+vadj,275+hadj SIZE 80,30   
    GOSUB LoadImage
    GOSUB GetScreen

GetInputFields:
'---------------------------------------------------------------------------------
'*** Loop through the input fields. If the button isn't pressed and we are at
'*** the last field, go back to the top. When adding a field, add one to the 
'*** "IF X=(n) THEN X=1" where (n) is one more than the field number being added.
'

'*** Build the initial GUI
    GOSUB drawinfobar
    X=1
    DO                            '*** Loops through the GUI until a button is pressed.
          IF TIME()-calc>30 THEN
             calc=TIME()
             GOSUB drawinfobar
          END IF
          FLD$=X
          GOSUB GET_INPUT
          GOSUB drawinfobar
          X+=1
          IF X=7 THEN X=1
          SLOWDOWN
    UNTIL BUTTON.SELECTED

   GOSUB GetAnswers


ExecuteCompare:
'---------------------------------------------------------------------------------
'*** Get input from screen and retrieve responses
'
    IF FILE_EXISTS(File1$)=FALSE THEN  
       a$&= "*** FILE "&File1$&" does not exist. Please correct."&cr$
       FILE_DOESNT_EXIST=TRUE
    ENDIF

    IF FILE_EXISTS(File2$)=FALSE THEN
       a$&= "*** FILE "&File2$&" does not exist. Please correct."&cr$
       FILE_DOESNT_EXIST=TRUE
    ENDIF

    IF FILE_DOESNT_EXIST THEN 
       FIELD "result" TEXT a$
       FILE_DOESNT_EXIST=FALSE
       BUTTON.SELECTED=FALSE
       GOTO GetInputFields
    ENDIF

    FILE File1$ SETPOS 0!FILE File1$ RESET
    FILE File2$ SETPOS 0!FILE File2$ RESET

    t1=0!t2=0!t=0
    endflag1=FALSE!endflag2=FALSE

'*** Library/Insert File Compare Program code
    prevresult=1
    timecount=TIME()
    a$ = "File1 pathname = "&File1$&cr$
    a$&= "File2 pathname = "&File2$&cr$&cr$
    a$&= "    File1 size = "&FILE_SIZE(File1$)&" bytes    "
    a$&= "    File2 size = "&FILE_SIZE(File2$)&" bytes    "&cr$&cr$
    FIELD "result" FONT NAME "Menlo-Regular" 
    FIELD "result" FONT SIZE 17
    FIELD "result" TEXT a$


LOOP:
'--------------------------------------------------------------------------------------------
'*** Loop through reading both files, compare each record, and report whether they are the
'*** same or not. Include use of processing switches to ignore blank records, display or hide
'*** matches, and indented lines.
'
       t+=1
       IF t<1000 THEN num$=t
       IF t<100  THEN num$="0"&t
       IF t<10   THEN num$="00"&t

'*** Processing File 1 (Should be newest file, but not necessary)
       IF NOT FILE_END(File1$) THEN 
          FILE File1$ READLINE temp1$
          hold1$=temp1$
          L=LEN(temp1$)
          IF EmptySpaces$="Y" THEN                  '*** If EmptySpaces is set, remove all spaces
             GOSUB ProcessEmptySpacesFile1
          ELSE
             IF Blanks$="Y" THEN                    '*** If set, remove all blank and null lines
                GOSUB ProcessBlankSwitchFile1
             ENDIF
             IF Indents$="Y" THEN                   '*** Process Indents unless EmptySpaces is set
                IF LEFT$(temp1$,1)=" " THEN temp1$=LTRIM$(temp1$) 
             ENDIF
          ENDIF 
       ELSE
          a$&="EOF – FILE 1"&cr$&cr$
          endflag1=TRUE
       ENDIF

'*** Processing File 2 (Should be oldest file, but not necessary)
       IF NOT FILE_END(File2$) THEN 
          FILE File2$ READLINE temp2$
          hold2$=temp2$
          L=LEN(temp2$)
          IF EmptySpaces$="Y" THEN                  '*** If EmptySpaces is set, remove all spaces
             GOSUB ProcessEmptySpacesFile2
          ELSE
             IF Blanks$="Y" THEN                    '*** If set, remove all blank and null lines
                GOSUB ProcessBlankSwitchFile2
             ENDIF			
             IF Indents$="Y" THEN                   '*** Process Indents unless EmptySpaces is set
                IF LEFT$(temp2$,1)=" " THEN temp2$=LTRIM$(temp2$) 
             ENDIF
          ENDIF 
       ELSE
          a$&="EOF – FILE 2"&cr$&cr$
          endflag2=TRUE
       ENDIF

'*** EOF Swtich processing to ensure all lines from the file that still has data are reported
       IF endflag1 AND endflag2  THEN GOTO skip 
       IF endflag1 OR  endflag2  THEN GOTO finishfile

'*** Check the lines from each file, report either MATCH or NO MATCH and go back to processing
'*** NOTE: SHOW/HIDE Matches Switch is processed here
       IF temp1$=temp2$ THEN
          result=1
          IF result<>prevresult THEN a$&=cr$
          IF Matches$="S" THEN a$&= num$&"  – MATCH: "&hold2$&cr$&cr$
          t2+=1
       ELSE
          result=0      
          IF result<>prevresult THEN a$&=cr$
          a$&= num$&" – NO MATCH:"&cr$
          a$&= "File1$: "&hold1$&cr$
          a$&= "File2$: "&hold2$&cr$&cr$
          t1+=1
       ENDIF

       prevresult=result
       FIELD "result" TEXT a$
       GOTO LOOP


finishfile:
'---------------------------------------------------------------------------------
'*** Check each file after an EOF has been detected on either or both. Process
'*** all lines from the file that has yet to reach EOF as "NO MATCH." When Version
'*** 4 (or 5) is coded, then new and old files must be properly inputted, for
'*** depending on which file stil has records, they will be labeled as either 
'*** "ADDED" or "DELETED" lines. Unless both files hit EOF togeter, only one file
'*** will have extra lines to deal with.
'
'*** Process from FILE 2 (Oldest) if there are sill records after FILE 1 status is EOF.
       IF endflag1 THEN
          result=0      
          IF result<>prevresult THEN a$&=cr$
          a$&= num$&" – NO MATCH:"&cr$
          a$&= "File2$: "&hold2$&cr$&cr$
          t1+=1!t+=1!num$=t
          DO
                FILE File2$ READLINE temp2$
                hold2$=temp2$
                IF NOT FILE_END(File2$) THEN      
                   a$&=cr$
                   a$&= num$&" – NO MATCH:"&cr$
                   a$&= "File2$: "&hold2$&cr$&cr$
                   t1+=1!t+=1!num$=t
                ELSE
                   a$&=cr$&"EOF – FILE 2"&cr$&cr$
                   endflag2=TRUE
                ENDIF
          UNTIL endflag2
       ENDIF

'*** Process from FILE 1 (Newest) if there are sill records after FILE 2 status is EOF.
       IF endflag2 THEN
          result=0     
          IF result<>prevresult THEN a$&=cr$
          a$&= num$&" – NO MATCH:"&cr$
          a$&= "File1$: "&hold1$&cr$&cr$
          t1+=1!t+=1!num$=t
          DO
                FILE File1$ READLINE temp1$
                hold1$=temp1$
                IF NOT FILE_END(File1$) THEN
                   a$&=cr$
                   a$&= num$&" – NO MATCH:"&cr$
                   a$&= "File1$: "&hold1$&cr$&cr$
                   t1+=1!t+=1!num$=t
                ELSE
                   a$&=cr$&"EOF – FILE 1"&cr$&cr$
                   endflag1=TRUE
                ENDIF
          UNTIL endflag1
       ENDIF

skip:
'---------------------------------------------------------------------------------
'*** When both files have been completely processed, print out stats and signal 
'*** with an audible "BEEP"(3 or them) then go to beginning of process in case
'*** you want to process another file or new set of files, changes processing
'*** switches, etc.
'
       duration=INT(TIME()-timecount)
       a$&=" Total Records MATCHED: "&t2&cr$
       a$&="Total Records NO MATCH: "&t1&cr$&cr$&cr$
       a$&="Comparison took "&duration&" seconds"&cr$&cr$&cr$&cr$&cr$&cr$&cr$&cr$
       FIELD "result" TEXT a$
       BEEP!BEEP!BEEP
       BUTTON.SELECTED=FALSE
       GOTO GetInputFields


'*** End Of Program Routine
ENDProg:
    STOP

'
'*** END Main Program Logic
'-----------------------------------------------------------------------------


'*** SUBROUTINES AND FUNCTIONS ***

GetAnswers:
'------------------------------------------------------------------------------
'*** Get the input into the variables from the screen
'
    File1$       = FIELD_TEXT$("1")
    File2$       = FIELD_TEXT$("2")
    Matches$     = CAPSTR$(FIELD_TEXT$("3"))
    Blanks$      = CAPSTR$(FIELD_TEXT$("4"))
    Indents$     = CAPSTR$(FIELD_TEXT$("5"))
    EmptySpaces$ = CAPSTR$(FIELD_TEXT$("6"))


RETURN


GetScreen:
'-----------------------------------------------------------------
'*** Define and draw the screen elements
'
    DRAW COLOR 0,0,0
    FILL COLOR 0,0,0
    DRAW TEXT "FILE COMPARE v3.0 – Extensive File Comparison" AT 240,30+hadj

'----------------------------------------------------------------------------------
'*** Set Default Screen Values and display the screen with input fields and buttons
'
    Matches$      = "H"
    Blanks$       = "N"
    Indents$      = "N"
    EmptySpaces$  = "Y"

    DRAW TEXT "Enter New File:"                AT 6+vadj,82+hadj
    FIELD "1" TEXT File1$                      AT 200+vadj,80+hadj  SIZE 700,25
    DRAW TEXT "Enter Old File:"                AT 6+vadj,112+hadj
    FIELD "2" TEXT File2$                      AT 200+vadj,110+hadj SIZE 700,25
    
    DRAW TEXT "PROCESSING SWITCHES"            AT 6+vadj,170+hadj

    DRAW TEXT "Show/Hide Matches:"             AT 6+vadj,195+hadj
    FIELD "3" TEXT Matches$                    AT 223+vadj,192+hadj SIZE 25,25

    DRAW TEXT "Ignore Blank Lines:"            AT 280+vadj,195+hadj
    FIELD "4" TEXT Blanks$                     AT 510+vadj,192+hadj SIZE 25,25

    DRAW TEXT "Ignore Indented Spaces:"        AT 560+vadj,195+hadj
    FIELD "5" TEXT Indents$                    AT 837+vadj,192+hadj SIZE 25,25

    DRAW TEXT "Ignore All Spaces:"             AT 6+vadj,222+hadj
    FIELD "6" TEXT EmptySpaces$                AT 223+vadj,222+hadj SIZE 25,25

    DRAW TEXT "Results of File Comparison:"    AT 06,300+adj
    FIELD "result" TEXT ""                     AT 6,310+hadj SIZE sw-12,sh-100 ML RO


RETURN


GET_INPUT:
'--------------------------------------------------------------------
'*** Determines when screen field changes or if button is pressed
'*** Update fields when either a field value changes or a button is
'*** pressed.
'
    FIELD FLD$ BACK COLOR 1,1,0
    FIELD FLD$ FONT NAME "Courier"
    FIELD FLD$ SELECT

    DO

       IF TIME()-calc>30 THEN
          calc=TIME()
          GOSUB drawinfobar
       END IF

'*** Process when the COMPARE button is pressed
       IF BUTTON_PRESSED("comp") THEN
          BUTTON.SELECTED=.TRUE
       ENDIF

'*** Process when either the QUIT or the Drawbar QUIT(X) buttons are pressed
       IF BUTTON_PRESSED("quit") OR BUTTON_PRESSED("quit2") THEN
          BUTTON.SELECTED=.TRUE
          GOTO ENDProg
       ENDIF

       SLOWDOWN

    UNTIL FIELD_CHANGED(FLD$) OR BUTTON.SELECTED
    FIELD FLD$ BACK COLOR 1,1,1  


RETURN


LoadImage:
'------------------------------------------------------------------
'*** Code that gets and draws the image for the top half of screen.
'

    DRAW IMAGE "Images/scope.jpg" AT 0,imy SCALE rw*.5


RETURN


drawinfobar:
'---------------------------------------------------------------
'*** custom top toolbar (Thanks to Dav for this code)
'

'*** Create custom top toolbar
    pfactor=.4 ' sets range of battery indicator
    t$="Battery"
    FILL ALPHA 0
    aj=.sw/5
    ratw=.ratw!rath=.rath
    ypos=3
    SET BUTTONS CUSTOM
    SET BUTTONS FONT SIZE 18*ratw

'*** show device info
    sv$=DEVICE_TYPE$()&" with iOS "&SYSTEM_VERSION()

'*** show time
    ampm$="AM" ! hr=CURRENT_HOUR()
    MIN$=STR$(CURRENT_MINUTE())
    IF LEN(MIN$)=1 THEN MIN$="0"&MIN$
    IF hr>11 THEN ampm$="PM"
    IF hr>12 THEN hr=hr-12
    IF hr=0 THEN hr=12
    tm$=STR$(hr)&":"&MIN$&" "&ampm$
    tx=((sw/2)-TEXT_WIDTH(tm$)/2)

'*** show battery condition
    bat$=STR$(BATTERY_LEVEL())&"%"
    lev=BATTERY_LEVEL()
    tat=BATTERY_STATE ()
    IF tat THEN tat$="~" ELSE tat$=""
    DRAW COLOR 1,1,0
    DRAW ALPHA 1
    BUTTON "debug" TEXT CHR$(8545) AT 4,ypos-8
    BUTTON "debug2" TEXT CHR$(8545) AT 4,ypos-8
    BUTTON "dev" TEXT sv$ AT 28*ratw,ypos-8
    BUTTON "app" TEXT app$ AT sw/2-TEXT_WIDTH(bat$)/2*ratw,ypos-8
    BUTTON "bat" TEXT bat$ AT sw-aj-TEXT_WIDTH(bat$)-60*ratw,ypos-8
    BUTTON "tat" TEXT tat$ AT sw-aj-TEXT_WIDTH(tat$)+41*ratw,ypos-8
    BUTTON "time" TEXT tm$ AT tx-250*ratw,ypos-8
    BUTTON "quit2" TEXT "X" AT sw-34,ypos-8

'*** draw battery graphics
    FILL ALPHA 1
    DRAW ALPHA 1
    DRAW SIZE 1
    SHADOW OFFSET 0,0
    FILL COLOR 1,1,0
    DRAW COLOR 1,1,0
    levfactor=ratw*pfactor
    DRAW SIZE 1
    DRAW RECT sw-aj-45*ratw,ypos+2*rath TO sw-aj-4*ratw,ypos+14*rath
    FILL RECT sw-aj-45*ratw,ypos+2*rath TO sw-aj-44*ratw+lev*levfactor,ypos+14*rath
    FILL RECT sw-aj-5*ratw,ypos+5*rath TO sw-aj-2*ratw,ypos+11*rath
    tat=BATTERY_STATE ()
    IF tat THEN tat$="ϟ" ELSE tat$=""         ' Show ϟ if battery is charging
    BUTTON "tat" TEXT tat$
    DRAW COLOR 0,0,0
    FILL COLOR 1,1,1
    SET BUTTONS FONT SIZE 22*ratw
    DRAW ALPHA .7


RETURN


'--------------------------------------------------------------------------------------------
'*** START OF COMPARE PROCESSING CODE SUBROUTINES FOR FILE1 AND FILE 2
'***
'


ProcessEmptySpacesFile1:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   IF LEFT$(temp1$,1)=" " THEN temp1$=LTRIM$(temp1$)
   IF temp1$=NULL$ OR LEFT$(temp1$,L)=LEFT$(SPACES$,L) THEN
      GOSUB ProcessBlankSwitchFile1
   ENDIF
   GOSUB ProcessEmptySpacesSwitchFile1

RETURN


ProcessEmptySpacesSwitchFile1:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   S$=" " 
   SPLIT temp1$ TO TB$,V WITH S$
   temp1$=NULL$
   FOR X=1 TO V
       temp1$=temp1$&TB$(X)
   NEXT X


RETURN


ProcessBlankSwitchFile1:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   IF temp1$=NULL$ OR LEFT$(temp1$,L)=LEFT$(SPACES$,L) THEN
      NONBLANK=FALSE
      DO
            IF NOT FILE_END(File1$) THEN 
               FILE File1$ READLINE temp1$
               hold1$=temp1$
               IF temp1$<>NULL$ THEN NONBLANK=TRUE
            ELSE
               a$&=cr$&"EOF – FILE 1"&cr$&cr$
               endflag1=TRUE!NONBLANK=TRUE
            ENDIF
      UNTIL NONBLANK
   ENDIF


RETURN



ProcessEmptySpacesFile2:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   IF LEFT$(temp2$,1)=" " THEN temp2$=LTRIM$(temp2$)
   IF temp2$=NULL$ OR LEFT$(temp2$,L)=LEFT$(SPACES$,L) THEN
      GOSUB ProcessBlankSwitchFile2
   ENDIF
   GOSUB ProcessEmptySpacesSwitchFile2

RETURN


ProcessEmptySpacesSwitchFile2:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   S$=" " 
   SPLIT temp2$ TO TB$,V WITH S$
   temp2$=NULL$
   FOR X=1 TO V
       temp2$=temp2$&TB$(X)
   NEXT X


RETURN


ProcessBlankSwitchFile2:
'------------------------------------------------------------------
'*** Code that Processes file when Empty Spaces Swith is set on
'
   IF temp2$=NULL$ OR LEFT$(temp2$,L)=LEFT$(SPACES$,L) THEN
      NONBLANK=FALSE
      DO
            IF NOT FILE_END(File2$) THEN 
               FILE File2$ READLINE temp2$
               hold2$=temp2$
               IF temp2$<>NULL$ THEN NONBLANK=TRUE
            ELSE
               a$&=cr$&"EOF – FILE 2"&cr$&cr$
               endflag2=TRUE!NONBLANK=TRUE
            ENDIF
      UNTIL NONBLANK
   ENDIF


RETURN

'
'***
'*** END OF COMPARE PROCESSING CODE SUBROUTINES FOR FILE1 AND FILE 2
'--------------------------------------------------------------------------------------------

Following Files To Download:
Attachments
ELIZA.sb.txt
Remove .txt (Data Directory)
(9.51 KiB) Downloaded 350 times
ELIZA Copy.sb.txt
Remove .txt (Data Directory)
(9.51 KiB) Downloaded 337 times
ELIZA Old.sb.txt
Remove .txt (Data Directory)
(9 KiB) Downloaded 342 times
File Compare – Showing Its Features.txt
File Compare – Showing Its Features.txt (Documentation Directory)
(5.66 KiB) Downloaded 339 times
File Compare – Instructions.txt
File Compare – Instructions.txt - (Documentation Directory)
(4.61 KiB) Downloaded 321 times
File Compare – Readme.txt
File Compare – Readme (Main Directory)
(5.78 KiB) Downloaded 324 times
Background (Images Directory)
Background (Images Directory)
scope.jpg (276.84 KiB) Viewed 2246 times
George McGinn
Computer Scientist/Cosmologist/Writer/Photographer
Member: IEEE, IEEE Computer Society
IEEE Sensors Council & IoT Technical Community
American Association for the Advancement of Science (AAAS)

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: File Compare 3

Post by rbytes »

Thanks, George. I have it downloaded from Dropbox and will give it a try tonight.
The only thing that gets me down is gravity...

Post Reply