Advise on the following example

General FreeBASIC programming questions.
angros47
Posts: 2324
Joined: Jun 21, 2005 19:04

Re: Advise on the following example

Post by angros47 »

I see. I can tell you that any attempt to use it on DosBox (the emulator) are doomed to fail (so, people who have a 64 bit system might have only dosbox to test FreeBasic, and for them it will always fail)
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Advise on the following example

Post by Gablea »

Ok so let me see if I have this correct

I can start a thread that would print Ramdom numbers to the Hiden screen and at the same time having the normal screen data printed and then displayed

Will the random data not be over rotten by the standard screen data?

As I use a CLS before starting to write the standard screen data to the display.
paul doe
Moderator
Posts: 1733
Joined: Jul 25, 2017 17:22
Location: Argentina

Re: Advise on the following example

Post by paul doe »

Gablea wrote: Jul 10, 2022 19:10 ...
I can start a thread that would print Ramdom numbers to the Hiden screen and at the same time having the normal screen data printed and then displayed
...
Have you not checked the example I posted before? It solves your problem already...
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Advise on the following example

Post by dodicat »

Gablea
Remember
viewtopic.php?p=237846&hilit=%2Ataskkill%2A#p237846
DOS cannot handle dll files (or with extreme pain maybe) or threading (with extreme pain maybe), but dos applications freely used external .exe files.
Alphameric DOS pos system was used for years by newsagents, and, because it ran on winXP, it was used for years more.
It had many external .exe files.
I have adjusted my code from the link above slightly
fbtime.bas

Code: Select all

'fbtime.bas
'compile with -s gui to fbtime.exe if fbc<1.09 version
 #if __fb_version__ >= str(1.09)
#cmdline "-s gui"
#endif
#include "fbgfx.bi"
#include "vbcompat.bi"

dim as integer x=val(command(1))
dim as integer y=val(command(2))
screenres 200,32,8,,FB.GFX_NO_FRAME or FB.GFX_ALWAYS_ON_TOP
screencontrol 100,x+65-50,y+490-50 

width 200\8,32\16
color 0, 15

dim as string t1,t2
do
    t1=time
    screenlock
if t1<>t2 then 
    line(0,0)-(199,31),0,bf
    line(0,0)-(199,31),15,b
    draw string(10,15),Format(Now,"dd/mm/yyyy"),15
    draw string(100,15),format(Now,"hh:mm:ss"),15
end if
screenunlock
sleep 900
    t2=t1
loop
beep
end

  
And the running file

Code: Select all

 
 'compile with option -s gui  if fbc<1.09 version
 #if __fb_version__ >= str(1.09)
 #cmdline "-s gui" 
 #endif
#include "vbcompat.bi"
#include "fbgfx.bi"
using fb
declare Sub PoSScreen
declare Sub readstring(st As String,message As String)
dim shared as integer AppVersion=2017
dim shared as integer totaldue=13
dim shared as integer BarcodeNumber
dim shared as integer x,y

Sub StartPoSMode
   
 shell "start fbtime.exe " &(x) & " " &(y)  'run fbtime.exe
 
   dim as string _in,tmp
   screenset 1,0
      Do 
          cls
         PoSScreen                'Displays the screen
       
         Locate 26,54 : readstring "Barcode : ", _in
         locate 26,65:print _in
         if len(_in) then tmp=_in
         barcodenumber=valulng(tmp)
         _in=""
         flip
         sleep 1
      Loop until  lcase(tmp)="q"
      shell "taskkill /F /IM fbtime.exe"       'close fbtime.exe
      end
   End Sub
   
   
   
   dim as long w,h
   w=650  'widtt
   h=500  'height
   x=150   'screenposition x
   y=150   'screenposition y
 screenres w,h,8,2,FB.GFX_NO_FRAME
 
 width w\8,h\16
 screencontrol SET_WINDOW_POS,x,y


startposmode


 Sub PoSScreen
      Print " " & Chr(201) & String(76,Chr(205)) & Chr(187)
      Print " " & Chr(186) & "algPoS                                                             SimplePoS" & Chr(186)
      Print " " & Chr(186) & "EPoS Made Simple                                             Version " & AppVersion & Chr(186)
      Print " " & Chr(204) & String(76,Chr(205)) & Chr(185)
      Print " " & Chr(186) & Chr(201) & String(30,Chr(205)) & Chr(187) & " " & Chr(201) & String(41,Chr(205)) & Chr(187) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(30," ") & Chr(186) & " " & Chr(186) & String(41," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(30," ") & Chr(186) & " " & Chr(186) & String(41," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(200) & String(30,Chr(205)) & Chr(188) & " " & Chr(200) & String(41,Chr(205)) & Chr(188) & Chr(186)

      Print " " & Chr(186) & Chr(201) & String(74,Chr(205)) & Chr(187) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(204) & String(74,Chr(205)) & Chr(185) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(200) & String(74,Chr(205)) & Chr(188) & Chr(186)
      Print " " & Chr(204) & String(76,Chr(205)) & Chr(185)
      Print " " & Chr(186) & "                                                                            " & Chr(186)
      Print " " & Chr(200) & String(76,Chr(205)) & Chr(188);
      locate 12,12
      print "barcodenumber";barcodenumber
   
        Locate 6,5 : Print "Total"
        Locate 7,5 : Print "  Due"

        Locate 6,38 : Print "Cashier"
        Locate 6,65 : Print "Trans"
        Locate 6,74 : Print "PoS"
        
        Locate 7,38 : Print "0000 ********************"
        Locate 7,65 : Print "00001"
        Locate 7,74 : Print "001"
        
        dim as string s="Enter your numerical barcode"
        static as long x
        x+=1
        draw string(x,300),s
        draw string(x-650,300),s
        if x>650 then x=1

   
      If TotalDue = 0 Then
         Locate 26,5 : Print "Next Customer Please"
      Else
         Locate 26,5 : Print "Next Item Please (q to end program)"
      End If
     
End Sub 


Sub readstring(st As String,message As String)
    Static As String j,blink
    Static As Double t,lt
    Static As Long lft
    If lt-t>.5 Then blink="_"
    If lt-t>1 Then t=Timer:blink=" "
    Dim As String i=Inkey
    lft=Iif(Len(i),i[0],-1)
    If Lft=08 Then j=Mid(j,1,Len(j)-1)'backspace
    If lft>=0 Andalso lft<=254 Andalso lft<>8 Then j=j+Chr(Lft)
    If Lft=27 Then j=""               'esc clears the line
    If lft<>13 Then
        Print st & j & blink
    Else
        j=Rtrim(j,Chr(13))
        message=j
        j=""
    End If
    lt=Timer
End Sub


  
I can only guess that it will run in DOS.
for Linux
shell "taskkill /F /IM fbtime.exe"
should be changed to kill fbtime or something similar.
Note: I have used screenset 1,0 and flip, but screenlock and screenunlock will do also.

I think that some of these old shopkeepers, with one foot in the grave already, would probably like to use an updated DOS system.
They never seem to retire do they? One in the next village to mine is nearly eighty, and still runs his independent grocery shop with Post Office.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Advise on the following example

Post by srvaldez »

hello dodicat :)
have you heard of the HX DOS extender ?
see also http://web.archive.org/web/201409041751 ... de/HX.html
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Advise on the following example

Post by dodicat »

Hi srvaldez.
I was thinking of using
https://archive.org/details/ms-dos-6.22_dvd
and booting straight to dos when needed
I can add freebasic for dos to the writable cd maybe after I have written the iso file to it.
I used to mess around like this all the time in the days of XP.
Sometimes things worked, sometimes not.
I even had the bootloader (grub) set up on a bootable cd, and the rest of Linux on a separate hard drive, which I inserted into the computer.
If I wanted Linux, I popped in the cd and started the computer.
But since Win 10 I have avoided these experiments.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: Advise on the following example

Post by srvaldez »

I have a VM with MS-DOS installed but it's a pain to transfer files to it not to mention that I forgot most about DOS and have to constantly search the web for answers, after so many years of using Windows I find DOS too restrictive
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Re: Advise on the following example

Post by Gablea »

dodicat wrote: Jul 11, 2022 12:37 Gablea
Remember
viewtopic.php?p=237846&hilit=%2Ataskkill%2A#p237846
DOS cannot handle dll files (or with extreme pain maybe) or threading (with extreme pain maybe), but dos applications freely used external .exe files.
Alphameric DOS pos system was used for years by newsagents, and, because it ran on winXP, it was used for years more.
It had many external .exe files.
I have adjusted my code from the link above slightly
fbtime.bas

Code: Select all

'fbtime.bas
'compile with -s gui to fbtime.exe if fbc<1.09 version
 #if __fb_version__ >= str(1.09)
#cmdline "-s gui"
#endif
#include "fbgfx.bi"
#include "vbcompat.bi"

dim as integer x=val(command(1))
dim as integer y=val(command(2))
screenres 200,32,8,,FB.GFX_NO_FRAME or FB.GFX_ALWAYS_ON_TOP
screencontrol 100,x+65-50,y+490-50 

width 200\8,32\16
color 0, 15

dim as string t1,t2
do
    t1=time
    screenlock
if t1<>t2 then 
    line(0,0)-(199,31),0,bf
    line(0,0)-(199,31),15,b
    draw string(10,15),Format(Now,"dd/mm/yyyy"),15
    draw string(100,15),format(Now,"hh:mm:ss"),15
end if
screenunlock
sleep 900
    t2=t1
loop
beep
end

  
And the running file

Code: Select all

 
 'compile with option -s gui  if fbc<1.09 version
 #if __fb_version__ >= str(1.09)
 #cmdline "-s gui" 
 #endif
#include "vbcompat.bi"
#include "fbgfx.bi"
using fb
declare Sub PoSScreen
declare Sub readstring(st As String,message As String)
dim shared as integer AppVersion=2017
dim shared as integer totaldue=13
dim shared as integer BarcodeNumber
dim shared as integer x,y

Sub StartPoSMode
   
 shell "start fbtime.exe " &(x) & " " &(y)  'run fbtime.exe
 
   dim as string _in,tmp
   screenset 1,0
      Do 
          cls
         PoSScreen                'Displays the screen
       
         Locate 26,54 : readstring "Barcode : ", _in
         locate 26,65:print _in
         if len(_in) then tmp=_in
         barcodenumber=valulng(tmp)
         _in=""
         flip
         sleep 1
      Loop until  lcase(tmp)="q"
      shell "taskkill /F /IM fbtime.exe"       'close fbtime.exe
      end
   End Sub
   
   
   
   dim as long w,h
   w=650  'widtt
   h=500  'height
   x=150   'screenposition x
   y=150   'screenposition y
 screenres w,h,8,2,FB.GFX_NO_FRAME
 
 width w\8,h\16
 screencontrol SET_WINDOW_POS,x,y


startposmode


 Sub PoSScreen
      Print " " & Chr(201) & String(76,Chr(205)) & Chr(187)
      Print " " & Chr(186) & "algPoS                                                             SimplePoS" & Chr(186)
      Print " " & Chr(186) & "EPoS Made Simple                                             Version " & AppVersion & Chr(186)
      Print " " & Chr(204) & String(76,Chr(205)) & Chr(185)
      Print " " & Chr(186) & Chr(201) & String(30,Chr(205)) & Chr(187) & " " & Chr(201) & String(41,Chr(205)) & Chr(187) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(30," ") & Chr(186) & " " & Chr(186) & String(41," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(30," ") & Chr(186) & " " & Chr(186) & String(41," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(200) & String(30,Chr(205)) & Chr(188) & " " & Chr(200) & String(41,Chr(205)) & Chr(188) & Chr(186)

      Print " " & Chr(186) & Chr(201) & String(74,Chr(205)) & Chr(187) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(204) & String(74,Chr(205)) & Chr(185) & Chr(186)
      Print " " & Chr(186) & Chr(186) & String(74," ") & Chr(186) & Chr(186)
      Print " " & Chr(186) & Chr(200) & String(74,Chr(205)) & Chr(188) & Chr(186)
      Print " " & Chr(204) & String(76,Chr(205)) & Chr(185)
      Print " " & Chr(186) & "                                                                            " & Chr(186)
      Print " " & Chr(200) & String(76,Chr(205)) & Chr(188);
      locate 12,12
      print "barcodenumber";barcodenumber
   
        Locate 6,5 : Print "Total"
        Locate 7,5 : Print "  Due"

        Locate 6,38 : Print "Cashier"
        Locate 6,65 : Print "Trans"
        Locate 6,74 : Print "PoS"
        
        Locate 7,38 : Print "0000 ********************"
        Locate 7,65 : Print "00001"
        Locate 7,74 : Print "001"
        
        dim as string s="Enter your numerical barcode"
        static as long x
        x+=1
        draw string(x,300),s
        draw string(x-650,300),s
        if x>650 then x=1

   
      If TotalDue = 0 Then
         Locate 26,5 : Print "Next Customer Please"
      Else
         Locate 26,5 : Print "Next Item Please (q to end program)"
      End If
     
End Sub 


Sub readstring(st As String,message As String)
    Static As String j,blink
    Static As Double t,lt
    Static As Long lft
    If lt-t>.5 Then blink="_"
    If lt-t>1 Then t=Timer:blink=" "
    Dim As String i=Inkey
    lft=Iif(Len(i),i[0],-1)
    If Lft=08 Then j=Mid(j,1,Len(j)-1)'backspace
    If lft>=0 Andalso lft<=254 Andalso lft<>8 Then j=j+Chr(Lft)
    If Lft=27 Then j=""               'esc clears the line
    If lft<>13 Then
        Print st & j & blink
    Else
        j=Rtrim(j,Chr(13))
        message=j
        j=""
    End If
    lt=Timer
End Sub


  
I can only guess that it will run in DOS.
for Linux
shell "taskkill /F /IM fbtime.exe"
should be changed to kill fbtime or something similar.
Note: I have used screenset 1,0 and flip, but screenlock and screenunlock will do also.

I think that some of these old shopkeepers, with one foot in the grave already, would probably like to use an updated DOS system.
They never seem to retire do they? One in the next village to mine is nearly eighty, and still runs his independent grocery shop with Post Office.

This is why I'm trying to create a low cost system to help the independent retailers. I only picked dos due to I know how to configure it etc but I'm am experimenting with Debian 11

Say I have a small app that poles the serial port how would I communicate with my main app the data that is pooled from the port?

Example

Pos.exe is the main program
Port1.exe is a headless app that takes serial data from the comport and somehow sends it to the PoS app
Post Reply