Can someone help me with this code

General FreeBASIC programming questions.
Post Reply
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Can someone help me with this code

Post by Gablea »

Code: Select all

        Open "COM2:9600,N,8,1,CD0,CS0,DS0,BIN" FOR INPUT AS #1
                CLS
                PRINT "Scanned Barcodes"
               
                DO
                        DO
                          INPUT #1, BarcodeData$
                        LOOP WHILE BarcodeData$ = ""

                        PRINT " Scanned barcode Number : " + BarcodeData$

                        IF INKEY$ = CHR$(27) THEN
                           CLOSE #1
                           END
                        END IF
                LOOP
Can someone help me with the above code. this is in QBasic and it works
I would need someone to advice me how I can convert it into FB code.
It Work if i use the -lang QB option when I run the program BUT my problem is i want to intergrate this (so i can add Serial barcode Readers to my project) and the complete project is done in true FB

some advice or a example could would be great as I have spend 3months trying to figure this out

Thanks
Andy
phishguy
Posts: 1201
Joined: May 05, 2006 16:12
Location: West Richland, Wa

Post by phishguy »

The following example should work.

Code: Select all

Dim barcodedata As String
Open com "COM2:9600,N,8,1,CD0,CS0,DS0,RS"  As #1
If Err <> 0 Then
    Print "Error opening serial port!"
    Sleep
    End
End If

Cls
Print "Ready to scan Barcodes."
Print "Press 'esc' to quit"
Print                
Print "Scanned Barcodes"

Do
    While Loc(1) = 0
        If Inkey = Chr(27) Then
            Exit Do
        End If
        Sleep 1
    Wend
    
    Input #1, BarcodeData
    
    
    Print " Scanned barcode Number : " + BarcodeData
    
Loop
Print "Program aborted"
Sleep
Gablea
Posts: 1104
Joined: Apr 06, 2010 0:05
Location: Northampton, United Kingdom
Contact:

Post by Gablea »

THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU THANK-YOU


All I need to do now is work out how I can intergrate that in to my application below is the sub for the salescreen (bit basic at the moment as I am still figuring things out)

Code: Select all

	ItemsSold = 0
		Cls

		Line (0,0) - (800,600), white, BF 'Draws the white box at the top of the screen
	   Line (0,32) - (630,600), Grey, BF ' Draw the gray background for the sign off display
	   Line (0,580) - (630,600), Blue, BF ' Draws the blue background for the user task bar
	   
	   Line (10,40) - (300,80), black, BF' Draws the Sub total box
	   Line (400,40) - (600,80), black, BF' Draws the Item count box
	   
	   Line (10,90) - (600,500), white, BF' Draws the box for the current sale list
	   
	   Line (10,510) - (600,570), red, BF' Draws the box for the current sale list


		Do
		
		Dim KeyInString As String

		KeyInString = InKey
		
			
		If KeyInString = "0" Then KeyInPutData = KeyInPutData & "0"
		If KeyInString = "1" Then KeyInPutData = KeyInPutData & "1"
		If KeyInString = "2" Then KeyInPutData = KeyInPutData & "2"
		If KeyInString = "3" Then KeyInPutData = KeyInPutData & "3"
		If KeyInString = "4" Then KeyInPutData = KeyInPutData & "4"
		If KeyInString = "5" Then KeyInPutData = KeyInPutData & "5"
		If KeyInString = "6" Then KeyInPutData = KeyInPutData & "6"
		If KeyInString = "7" Then KeyInPutData = KeyInPutData & "7"
		If KeyInString = "8" Then KeyInPutData = KeyInPutData & "8"
	   If KeyInString = "9" Then KeyInPutData = KeyInPutData & "9"

		KeyInString = ""


			   text_scaler(20, 0+(3*16), 1, "Sub Total", white) ' Prints Sub total on the screen				
			  text_scaler(180, 10+(3*16), 3, Format(TotalDue, Chr$(156) & "######0.00"), white) ' Displays the Sub total value
				
			   text_scaler(410, 0+(3*16), 1, "Items Sold", white) ' Prints Items sold on the screen			
			  text_scaler(575, 10+(3*16), 3, "" & ItemsSold, white) ' Displays the items sold
						
				
				text_scaler(10, 537+(3*16), 1, RecTillNumber, White) ' Displys the till number
  				text_scaler(50, 537+(3*16), 1, Format(Now,"hh:mm"), White, Blue) ' Displays the time
  			  text_scaler(120, 537+(3*16), 1, Format(Now,"dd/mm/yyyy"), White, Blue) ' Displyas the Date
				
		  	  text_scaler(250, 537+(3*16), 1, "123456", White, Blue) ' Displyas the transacation number
		     text_scaler(300, 537+(3*16), 1, "1234", White, Blue) ' Displyas the Cashier number		  	  
		     text_scaler(350, 537+(3*16), 1, "12345678901234567890", White, Blue) 'displays the cashier name

				If TotalDue = 0 Then
			   	text_scaler(20, 470+(3*16), 2, "Next Customer Please", Black) ' displasy the Next customer please on the screen
				Else
			   	text_scaler(20, 470+(3*16), 1, "Scan / Key", Black) ' displasy the Next customer please on the screen
				   text_scaler(20, 500+(3*16), 1, "Next Item", Black) ' displasy the Next customer please on the screen			   	
				
				   text_scaler(290, 500+(3*16), 2, KeyInPutData, Black) ' displasy the Next customer please on the screen

			End If

		'Normal Keys

			
		'Shift Key
		If MultiKey(SC_LSHIFT) And MultiKey(SC_F1) Then SignOffQuestion ' F1 sign on key
		
		'Control Key 
		If MultiKey(SC_CONTROL) And MultiKey(SC_F1) Then End 'F1 End (remove when live) 
	Loop
Post Reply