Opportunity to make some Cash
Re: Opportunity to make some Cash
Maybe just ./fbtime for bash to start an executable.
I see there is a kill command which seems similar to taskkill.
Nevertheless, Linux is always bragging about the power of it's command line, surely starting and stopping an executable would be trivial.
With Win 10 here, I have no installation disk, so I am reluctant to try Linux on a usb stick.
I see there is a kill command which seems similar to taskkill.
Nevertheless, Linux is always bragging about the power of it's command line, surely starting and stopping an executable would be trivial.
With Win 10 here, I have no installation disk, so I am reluctant to try Linux on a usb stick.
Re: Opportunity to make some Cash
@dodicat
If them floppys works I would love to have a copy even just so I can add them to my old pos collection
I'm going to try that deprecate time idea etc tomorrow when I'm at my Linux machine
In the mean time I can upload to my web database server a fully working database and the last workingish version on my app with MySQL support.
Edited due to a spelling error (was on my iPhone when o replied)
If them floppys works I would love to have a copy even just so I can add them to my old pos collection
I'm going to try that deprecate time idea etc tomorrow when I'm at my Linux machine
In the mean time I can upload to my web database server a fully working database and the last workingish version on my app with MySQL support.
Edited due to a spelling error (was on my iPhone when o replied)
Re: Opportunity to make some Cash
hi @dodicat
if you could send me a message regarding them Floppy disk images I would most appreciate it
I still can not fix the date and time issue (as it stops when I am waiting for a user input) I have even though about just dumping my complete
code and starting from scratch (was reading on few other forums that i should have a BAS file for each screen / function tjhat I want and just call them from the main part of the program.
my Customers love the older machines as most if them have never used a EPoS system in thier life (they are coming from a old manual till to a scanning system) so the older hardware is my BASIC entry level system (hence why I am thinking about doing this in DOS / Linux Frame-buffer)
But they may be old machines but they are as powerful as the modern PoS systems with the right Operating system on them (I use Debian 9 on 512MB RAM and a 566 - 600 MHz CPU with no GUI interface so I am working from the text line and the software uses the Frame-buffer to display data and it works fine)
I appreciate all the input you all have given me over the years and I will admit I am Not a professional Programmer at all with the FreeBASIC language (i was a ok programmer with QBasic / PDS) but my skills are with Visual basic but because windows is becoming so bolted and requiring machines with silly amounts of ram to work I need to find alternatives for my customers)
I was thinking about redoing all my work again in PDS and then move it to FreeBASIC but that would be silly I should learn how to update the screen (or create separate threads for things like the date update and the serial barcode reader) IF It is possible to use threads for these things would I have to give up on a PURE DOS version (I know linux and Windows can support threading with in applications
IS there any where online a example of how to make a basic tread to update a time on screen while the program is doing something else?
if you could send me a message regarding them Floppy disk images I would most appreciate it
I still can not fix the date and time issue (as it stops when I am waiting for a user input) I have even though about just dumping my complete
code and starting from scratch (was reading on few other forums that i should have a BAS file for each screen / function tjhat I want and just call them from the main part of the program.
my Customers love the older machines as most if them have never used a EPoS system in thier life (they are coming from a old manual till to a scanning system) so the older hardware is my BASIC entry level system (hence why I am thinking about doing this in DOS / Linux Frame-buffer)
But they may be old machines but they are as powerful as the modern PoS systems with the right Operating system on them (I use Debian 9 on 512MB RAM and a 566 - 600 MHz CPU with no GUI interface so I am working from the text line and the software uses the Frame-buffer to display data and it works fine)
I appreciate all the input you all have given me over the years and I will admit I am Not a professional Programmer at all with the FreeBASIC language (i was a ok programmer with QBasic / PDS) but my skills are with Visual basic but because windows is becoming so bolted and requiring machines with silly amounts of ram to work I need to find alternatives for my customers)
I was thinking about redoing all my work again in PDS and then move it to FreeBASIC but that would be silly I should learn how to update the screen (or create separate threads for things like the date update and the serial barcode reader) IF It is possible to use threads for these things would I have to give up on a PURE DOS version (I know linux and Windows can support threading with in applications
IS there any where online a example of how to make a basic tread to update a time on screen while the program is doing something else?
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Using a thread in FreeBasic
Well I remember giving a solution to this where you write an input routine that is called continually in a main loop that also updates the date and time.Gablea wrote:hi @dodicat
if you could send me a message regarding them Floppy disk images I would most appreciate it
I still can not fix the date and time issue (as it stops when I am waiting for a user input)
With regards to threads I have never used them myself however below I have modified a FB thread example so it allows you to continually input data until you enter exit while at the same time updating the date and time. Not sure how to remove the flicker because screenlock/unlock just seems to freeze up the input command.
Code: Select all
#include "vbcompat.bi"
screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255):cls
Dim Shared terminate As Integer = 0
Sub mythread (param As Any Ptr)
Dim As Double t = Timer
While( 1 )
line (2*8,29*8)-(2*8+132,29*8+32),rgb(200,200,255),bf 'clear print area
draw string (2*8,29*8), Format(Now,"dd/mm/yyyy"),rgb(0,0,0)
draw string (2*8,30*8), Format(Now,"hh:mm:ss"),rgb(0,0,0)
If terminate=1 Then Exit Sub
sleep 10
Wend
End Sub
Dim thread As Any Ptr
Dim b As Integer
Dim As Double t
thread = ThreadCreate( @mythread, 0 )
dim as string reply
print "enter data. type exit to end"
do
input reply
sleep 2
loop until reply = "exit"
terminate=1
Print "Terminate launched";
ThreadWait (thread)
Print "Thread terminated"
Sleep
Re: Opportunity to make some Cash
@BasicCoder2
Thanks for that I shall see what I can do with that code
I am still thinking about dropping everything and starting a new that way I can incorporate new code and data methods (like SQL)
Thanks for that I shall see what I can do with that code
I am still thinking about dropping everything and starting a new that way I can incorporate new code and data methods (like SQL)
Re: Using a thread in FreeBasic
The flickering will disappear for most of the time if you insert the code below and StartHiResSleep (for some reason the flickering will reappear in between and then go away)BasicCoder2 wrote:Not sure how to remove the flicker because screenlock/unlock just seems to freeze up the input command.
(Code by deltarho[1859])(I think)
Code: Select all
#include "windows.bi"
#include "win/mmsystem.bi"
#Macro StartHiResSleep
Scope
Dim As TIMECAPS tc
TimeGetDevCaps( @tc, SizeOf(tc) )
TimeBeginPeriod(tc.wPeriodMin)
End Scope
Sleep (16,1) ' Tests have shown that the new resolution will not 'bite' until next 'old' tick
#EndMacro
StartHiResSleep
' at program exit can be inserted :
#Macro StopHiResSleep
Scope
Dim As TIMECAPS tc
TimeGetDevCaps( @tc, SizeOf(tc) )
TimeEndPeriod(tc.wPeriodMin)
End Scope
Sleep (2,1) ' Tests have shown that the new resolution will not 'bite' until next 'old' tick
#EndMacro
StopHiResSleep
Last edited by Trinity on Oct 10, 2017 21:45, edited 1 time in total.
Re: Opportunity to make some Cash
Jep, the best way IMHO, just don't forget: plan first and, again: some more planning, and only then: start coding ...Gablea wrote:I am still thinking about dropping everything and starting a new that way I can incorporate new code and data methods (like SQL)
What I'm trying to convey:
first step: define the different modules: UI, Serial, Network, SQL (etc.) and, the communication in between them.
second step: needed procedures (for every one, of above modules) as well as, communication interface (of module).
You might want to add a module, that contains procedures, shared by more than a specific module (utility's).
Last edited by MrSwiss on Oct 10, 2017 21:49, edited 1 time in total.
Re: Using a thread in FreeBasic
Yes, then a simple solution is to use double buffering:BasicCoder2 wrote:Not sure how to remove the flicker because screenlock/unlock just seems to freeze up the input command.
Code: Select all
#include "vbcompat.bi"
screenres 640,480,32,2
screenset 1, 0
color rgb(0,0,0),rgb(255,255,255):cls
Dim Shared terminate As Integer = 0
Sub mythread (byval param As Any Ptr)
screenset 1, 0
Dim As Double t = Timer
While( 1 )
line (2*8,29*8)-(2*8+132,29*8+32),rgb(200,200,255),bf 'clear print area
draw string (2*8,29*8), Format(Now,"dd/mm/yyyy"),rgb(0,0,0)
draw string (2*8,30*8), Format(Now,"hh:mm:ss"),rgb(0,0,0)
screencopy
If terminate=1 Then Exit Sub
sleep 10
Wend
End Sub
Dim thread As Any Ptr
Dim b As Integer
Dim As Double t
thread = ThreadCreate( @mythread, 0 )
dim as string reply
print "enter data. type exit to end"
do
input reply
sleep 2
loop until reply = "exit"
Print "Terminate launched"
terminate=1
ThreadWait (thread)
Print "Thread terminated"
Screencopy
Sleep
The two threads (in including the main thread) must share a same resource: the input/output device. So all input/output instructions must be protected by a mutex locking to avoid execution code collisions.
Because we can not protect "INPUT" by a mutex locking (otherwise the other threads would be blocked during the input characters waiting phase), its use with multi threading is not safe (crashing for example).
This seems to work in the example above, but it's lucky.
Last edited by fxm on Oct 15, 2017 20:18, edited 8 times in total.
Re: Opportunity to make some Cash
Yes I agree with you on the planning stage as I want to be able to stop selling my VB version as some point and use the FreeBASIC version on Linux as its replacement for it.MrSwiss wrote:Jep, the best way IMHO, just don't forget: plan first and, again: some more planning, and only then: start coding ...Gablea wrote:I am still thinking about dropping everything and starting a new that way I can incorporate new code and data methods (like SQL)
What I'm trying to convey:
first step: define the different modules: UI, Serial, Network, SQL (etc.) and, the communication in between them.
second step: needed procedures (for every one, of above modules) as well as, communication interface (of module).
You might want to add a module, that contains procedures, shared by more than a specific module (utility's).
Could you explain a little bit more of what you mean by Communication interface of module
Re: Opportunity to make some Cash
Well, modules have to be able to (simply put):Gablea wrote:Communication interface of module
ask questions / receive answers, from other modules (also called a protocol, sometimes).
Example:
to be able to use SQL, a established Network connection (client/server), is mandatory for *online* mode.
This is different, in case you are using a local copy of the DB. (then only if a sync. is wanted)
Meaning: Network call: first -- SQL call (at least the first time, after Network call), ... etc.
So, SQL would test for Network status, being OK, before doing anything else ... (ask Network status).
Re: Opportunity to make some Cash
that makes sense :)
Thanks I think I will be doing more digging around the net for examples etc before I do anything else this time
Thanks I think I will be doing more digging around the net for examples etc before I do anything else this time
Re: Using a thread in FreeBasic
To do not use double buffering but screen locking (with one single page), the code will be more complex:fxm wrote:Yes, then a simple solution is to use double buffering:BasicCoder2 wrote:Not sure how to remove the flicker because screenlock/unlock just seems to freeze up the input command.[edit]Code: Select all
#include "vbcompat.bi" screenres 640,480,32,2 screenset 1, 0 color rgb(0,0,0),rgb(255,255,255):cls Dim Shared terminate As Integer = 0 Sub mythread (byval param As Any Ptr) screenset 1, 0 Dim As Double t = Timer While( 1 ) line (2*8,29*8)-(2*8+132,29*8+32),rgb(200,200,255),bf 'clear print area draw string (2*8,29*8), Format(Now,"dd/mm/yyyy"),rgb(0,0,0) draw string (2*8,30*8), Format(Now,"hh:mm:ss"),rgb(0,0,0) screencopy If terminate=1 Then Exit Sub sleep 10 Wend End Sub Dim thread As Any Ptr Dim b As Integer Dim As Double t thread = ThreadCreate( @mythread, 0 ) dim as string reply print "enter data. type exit to end" do input reply sleep 2 loop until reply = "exit" Print "Terminate launched" terminate=1 ThreadWait (thread) Print "Thread terminated" Screencopy Sleep
The two threads (in including the main thread) must share a same resource: the input/output device. So all input/output instructions must be protected by a mutex locking to avoid execution code collisions.
Because we can not protect "INPUT" by a mutex locking (otherwise the other threads would be blocked during the input characters waiting phase), its use with multi threading is not safe (crashing for example).
This seems to work in the example above, but it's lucky.
- replace INPUT with INKEY, and emulate the INPUT function (minimum emulation below),
- protect the screen locking block (in the thread) and all the input/output instructions (in the main code) by a common mutex.
Code: Select all
#include "vbcompat.bi"
screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255):cls
Dim Shared terminate As Integer = 0
Dim Shared mutex As Any Ptr
Sub mythread (byval param As Any Ptr)
Dim As Double t = Timer
While( 1 )
mutexlock(mutex)
screenlock
line (2*8,29*8)-(2*8+132,29*8+32),rgb(200,200,255),bf 'clear print area
draw string (2*8,29*8), Format(Now,"dd/mm/yyyy"),rgb(0,0,0)
draw string (2*8,30*8), Format(Now,"hh:mm:ss"),rgb(0,0,0)
screenunlock
mutexunlock(mutex)
If terminate=1 Then Exit Sub
sleep 10
Wend
End Sub
print "enter data. type exit to end"
Dim thread As Any Ptr
Dim b As Integer
Dim As Double t
mutex = MutexCreate
thread = ThreadCreate( @mythread, 0 )
dim as string reply
dim as string in
do
mutexlock(mutex)
print "? ";
mutexunlock(mutex)
reply = ""
do
mutexlock(mutex)
in = inkey
if len(in) = 1 and asc(in) >= 32 then
print in;
reply &= in
end if
mutexunlock(mutex)
sleep 2
loop until in = chr(13)
mutexlock(mutex)
print
mutexunlock(mutex)
loop until reply = "exit"
terminate=1
mutexlock(mutex)
Print "Terminate launched"
mutexunlock(mutex)
sleep 2
ThreadWait (thread)
Print "Thread terminated"
Mutexdestroy(mutex)
Sleep
Last edited by fxm on Oct 15, 2017 20:21, edited 8 times in total.
-
- Posts: 3906
- Joined: Jan 01, 2009 7:03
- Location: Australia
Re: Opportunity to make some Cash
@fxm,
Thank you for that one. As I indicated I have never actually used threads in any language. I do see the value in them but usually work around Gablea's type of problem as shown below.
Thank you for that one. As I indicated I have never actually used threads in any language. I do see the value in them but usually work around Gablea's type of problem as shown below.
Code: Select all
#include "vbcompat.bi"
screenres 640,480,32
color rgb(0,0,0),rgb(255,255,255):cls
print "enter data. type exit to end"
dim as string reply
dim as string in
do
print "? ";
reply = ""
do
screenlock
in = inkey
if asc(in) >= 32 then
print in;
reply &= in
end if
line (2*8,29*8)-(2*8+132,29*8+32),rgb(200,200,255),bf 'clear print area
draw string (2*8,29*8), Format(Now,"dd/mm/yyyy"),rgb(0,0,0)
draw string (2*8,30*8), Format(Now,"hh:mm:ss"),rgb(0,0,0)
screenunlock
sleep 2
loop until in = chr(13)
print
loop until reply = "exit"
Sleep
Re: Opportunity to make some Cash
Only the 3 graphic code lines must be enclosed inside the screen locking block.
Re: Opportunity to make some Cash
@BasicCoder2
Your Code works great is it possible to move the "graphic" part into a sub (as I have one called DisplayTaskBar) would that work still or would that
make the system unstable? if it does work like how I was thinking do I call the DisplayTaskBar in every sub that uses a Loop (i.e. for the keyboard input functions) for example
This is the current DisplayTaskBar Sub Fucntion
that is the code I am at the moment using to show the sign on screen (and sometime when a user has not entered any text etc the time on screen
stops displays (the seconds)
I assume the code you just made would complie on DOS as it does not use any Advanced functions (like threading etc)
Your Code works great is it possible to move the "graphic" part into a sub (as I have one called DisplayTaskBar) would that work still or would that
make the system unstable? if it does work like how I was thinking do I call the DisplayTaskBar in every sub that uses a Loop (i.e. for the keyboard input functions) for example
Code: Select all
Sub SignOnScreen
ScreenLock
Cls
Put(0,0), BackGround_SigningOna, PSet
DisplayTaskBar
With font
.fontindex = 7
.backcolor = TransparentColour
.forecolor = Black
.drawstring(,DisplaySignonSpace(KeyPadInput),210,267)
End With
ScreenUnLock
Do : DisplayTaskBar : ProcessKey_SignOn(GetKeyNB)
Loop
End Sub
This is the current DisplayTaskBar Sub Fucntion
Code: Select all
Sub DisplayTaskBar
FileLocation_ToServer = ReadIniValue(DBSettingsFilePath, "Data locations", "ToServer")
Dim DisplayTimeMode As String = "12hrs+seconds"
ScreenLock
If RecipitOption = "Request" Then
Put (545,5), Background_RecipitOff, PSet
End If
If FileExists(FileLocation_ToServer & FileSeperator & "ok.txt") = TRUE Then
Put (505,5), Background_TaskbarBlank, PSet
NetworkOK = 0
Else
Put (505,5), Background_NoNetWork, PSet
NetworkOK = 1
End If
With font
.fontindex = 1
.backcolor = backgroundColor
.forecolor = black
.drawstring (,Format(Now,"dd/mm/yyyy"),255,582)
Select Case DisplayTimeMode
Case "12hrs+seconds"
.drawstring (,Format(Now,"hh:mm:ss tt"),355,582)
Case "12hrs"
.drawstring (,Format(Now,"hh:mm tt"),355,582)
Case "24hrs"
.drawstring (,Format(Now,"hh:mm"),355,582)
Case "24hrs+seconds"
.drawstring (,Format(Now,"HH:mm:ss tt"),355,582)
End Select
.drawstring (,Format(Val(Trim(PoSTerminalNumber)),"000"),465,582)
If ShowTaskBarItems = 1 Then
' .drawstring (,cashierNumber,450,582)
.drawstring (,PoSTransacationNumber,520,582)
End If
End With
ScreenUnLock
End Sub
stops displays (the seconds)
I assume the code you just made would complie on DOS as it does not use any Advanced functions (like threading etc)