This code is for the display of a coloured-strip analogue thermometer. It uses a graduated bitmap of colours, which are hidden by a moving white box.
' ___________________________________________________________________
' Illustrating an analogue meter display
' .. and a 'number of times run' technique.
' -------------------------------------------------------------------
nomainwin
open "MeterCountVersions.bas" for input as #b
l =lof( #b)
content$ =input$( #b, l)
close #b
version =asc( mid$( content$, l -50, 1)) -48
if version <100 then nv$ =chr$( version +1 +48) else [quit]
content$ =left$( content$, l -51); nv$; mid$( content$, l -49)
open "MeterCountVersions.bas" for output as #b
#b, content$;
close #b
graphicbox #Meter.g, 70, 70, 170, 10
statictext #Meter.st, "", 200, 40, 80, 30
statictext #Meter.st2, "", 100, 2, 80, 30
open "Progressing analogue display." for window as #Meter
#Meter, "trapclose [quit]"
#Meter.g, "down"
loadbmp "scale", "colours.bmp"
#Meter.g, "drawbmp scale 0 0"
#Meter.g, "flush"
#Meter.st2, "Used "; version; " times."
for i =0 to 60 step 0.1
temperature =1 +84 *( 1 +sin( i))
#Meter.st, int( temperature); " Celsius"
#Meter.g, "drawbmp scale 0 0"
#Meter.g, "place "; temperature; " 0"
#Meter.g, "backcolor white"
#Meter.g, "boxfilled 250 40"
#Meter.g, "flush"
timer 100, [on]
wait
[on]
timer 0
next i
wait
' _______________________________________________________________________
[quit]
close #Meter
end
' _______________________________________________________________________
'1111111111111111111111111111111111111111111111111111111111111111111111111111
'2222222222222222222222222222222222222222222222222222222222222222222222222222
'3333333333333333333333333333333333333333333333333333333333333333333333333333
'0000000000000000000000000000000000000000000000000000000000000000000000000000
Another version, which self-erases after 5 trial runs, or two weeks- whichever is the sooner.
You'd of course edit the references to the *.tkn that you would distribute...
' ___________________________________________________________________
' Illustrating an analogue meter display
' .. and a 'number of times run' technique.
' Try this program more than 5 times, or more than 14 days
' after first-running and it will refuse to run, and
' delete itself!
' -------------------------------------------------------------------
' It modifies itself.
' The same technique can be used to hide data
' in any other file in your distribution.
' If you modify the *.bas file, expect oddities if
' later you try to edit it.. keep a COPY!
' Normal use is to modify the *.tkn or (renamed) Run404.exe.
' 16 bytes are tacked on to the end.
' These hold count of times-used
' and Date/Timestamp of first run.
' Other bytes can be used for say a reg'n number..
' Users do not even have a way to know where
' the data are hidden.
' 'Obfuscation' ( cf 'steganography')
' http://libertybasic.conforums.com/index.cgi?board=LB3&action=display&num=1287397046
' has more, if you want to make it tied to a machine ID, ie once run
' on one machine it won't run on another.
' If they decide to buy a licence you send the owner another LB prog
' which takes out the existing checks and put in the hardware ID check.
' It will now run freely on their machine, but if copied to another will fail.
nomainwin
open "MeteredCount.bas" for input as #b
l =lof( #b)
content$ =input$( #b, l)
close #b
ID$ =right$( content$, 4)
if instr( ID$, "JHF") =0 then ' Unaltered file- so add the datestamp and times-used counter & 'JHF'.
content$ =content$ +"'" +right$( "0000000000000000" +str$( date$( "days")) +"__1" +"JHF", 15)
open "MeteredCount.bas" for output as #b
#b, content$;
close #b
end if
open "MeteredCount.bas" for input as #b
l =lof( #b)
content$ =input$( #b, l)
close #b
version =asc( mid$( content$, l -3, 1)) -48
if version <=5 then
nv$ =chr$( version +1 +48)
else
kill "MeteredCount.bas"
notice "SORRY!" +chr$( 13) +"Trial limit of runs exceeded!"
end
end if
if date$( "days") >= val( mid$( content$, l -10, 5)) +14 then
kill "MeteredCount.bas"
notice "SORRY!" +chr$( 13) +"Trial limit of days exceeded!"
end
end if
content$ =left$( content$, l -4)+ nv$ +right$( content$, 3)
open "MeteredCount.bas" for output as #b
#b, content$;
close #b
graphicbox #Meter.g, 70, 70, 170, 10
statictext #Meter.st, "", 200, 40, 80, 30
statictext #Meter.st2, "", 100, 2, 80, 30
open "Progressing analogue display." for window as #Meter
#Meter, "trapclose [quit]"
#Meter.g, "down"
loadbmp "scale", "colours.bmp"
#Meter.g, "drawbmp scale 0 0"
#Meter.g, "flush"
#Meter.st2, "Used "; version; " times."
for i =0 to 60 step 0.1
temperature =1 +84 *( 1 +sin( i))
#Meter.st, int( temperature); " Celsius"
#Meter.g, "drawbmp scale 0 0"
#Meter.g, "place "; temperature; " 0"
#Meter.g, "backcolor white"
#Meter.g, "boxfilled 250 40"
#Meter.g, "flush"
timer 100, [on]
wait
[on]
timer 0
next i
wait
' _______________________________________________________________________
[quit]
close #Meter
end
' Following line will have the data auto-inserted.
' In BASIC you see it. But change to tkn/exe form and only a hex
' editor can see it.
' _______________________________________________________________________