Page 1 of 1

Import Files advice

Posted: Sunday 4th June 2023 4:31pm
by AndyGable
Hello to all you super smart people out there,

I need to ask you all a question

I am trying to work out how to pull in some Java Drivers into my EPoS application

The Demo I was reading said I need to do this

import "jpos.JposException" 
import "jpos.POSPrinter"
import "jpos.util.JposPropertiesConst"

import "java.time.Duration"
import "java.time.Instant"


But When I try it says Missing As and the cursor is at the end of the first Line

This is what I am trying to run

   Dim f As File = New File("/algPoS/algPoS.xml")
    

    System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, f.getAbsolutePath());
    / / System.getProperties().list(System.out);
    
    FiscalPrinter fiscalPrinter = New FiscalPrinter();

    'This will print a recpit to the PoS printer via the JavaPoS Drivers
    POSPrinterControl113 printer = (jpos.POSPrinterControl113) New POSPrinter();
    CashDrawerControl113 drawer = (CashDrawerControl113) New CashDrawer();

    Try
        printer.open("POSPrinter")
        printer.claim(1000)
        printer.setDeviceEnabled(True)
        
     Catch (Exception e) 
        System.err.println("Printer deactivated " + e.getMessage())
        printerdisabled = True
        drawerdisabled = True
        Return 
    End Try
    
    Try 
        drawer.open("CashDrawer")
        drawer.claim(100)
        drawer.setDeviceEnabled(True)
     Catch (Exception e) 
        System.out.println("Cashdrawer deactivated: " + e.getMessage())
        drawerdisabled = True
        Return 
    End Try


This is a JavaPoS Interface (allows me to talk to ANY printer from any manufacturer as long as they have JavaPoS Drivers for it and I don't need to know how to program it as the JavaPoS does that for me)

If I can get this to work I can add so meany new features to my application(s) and have some of my old trusted functions back (like Cash drawer status)

Anyone have any idea how I can get this small section to work I would be greatful.

Re: Import Files advice

Posted: Sunday 4th June 2023 6:36pm
by BruceSteers
Er, convert it into gambas code because it isn't.

Re: Import Files advice

Posted: Sunday 4th June 2023 7:36pm
by AndyGable
The import jpos.JposException For example bring function into the software that is provided by a JavaPoS API (I assume I would use the import or do I load them in a different way)

So how would I import the functions I need in to Gambas?

How do I use the JavaPoS API inside my Gambas Application>

Re: Import Files advice

Posted: Sunday 4th June 2023 11:48pm
by AndyGable
ok I have done some updates to the code

I have changed the code that brings in the Libarys to

Library "jpos.JposException"
Library "jpos.POSPrinter" 
Library "jpos.util.JposPropertiesConst"
Library "java.time.Duration"
Library "java.time.Instant"


and now I am getting unknow idenifier on the JposPropertiesConst section of

System.setProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "/algPoS/algPoS.xml")


does anyone have any other idea as how to get this to work I feel i am getting close

Re: Import Files advice

Posted: Monday 5th June 2023 8:00am
by BruceSteers
System.setProperty() is not a gambas function

maybe you want Object.SetProperty() but probably not as it's not an object its a pointer to a library function.

Sorry i cannot help as i do not use external libraries at all.

Re: Import Files advice

Posted: Monday 5th June 2023 12:40pm
by AndyGable
BruceSteers wrote: Monday 5th June 2023 8:00am System.setProperty() is not a gambas function

maybe you want Object.SetProperty() but probably not as it's not an object its a pointer to a library function.

Sorry i cannot help as i do not use external libraries at all.
I must be doing something as when I type jpos. I get a list of all the function that I can use but at run time I get a error at the JposPropertiesConst part

Sometime I wish I went back to my DOS Systems (but that was still buggy)

Re: Import Files advice

Posted: Monday 5th June 2023 8:23pm
by AndyGable
Well after a little bit of googling I have sort of managed to import the libarys into Gambas

But now when I run the program I get the following error

POSPrinterControl113 posprinter = PoSPrinter.POSPrinterControl113 New RecipitPrinter

at the NEW location I get "Not a Object in FMain.class"

Any idea's where to go now guys?

This is my Code

Private JposException As Pointer Library "jpos.JposException"
Private PoSPrinter As Pointer Library "jpos.POSPrinter"
Private JposPropertiesConst As Pointer Library "jpos.util.JposPropertiesConst"

Public Sub btnOpenConnections_Click()

    'Object.SetProperty(JposPropertiesConst.JPOS_POPULATOR_FILE_PROP_NAME, "/algPoS/algPoS.xml", "")

    'This will print a recpit to the PoS printer via the JavaPoS Drivers
    POSPrinterControl113 posprinter = PoSPrinter.POSPrinterControl113 New RecipitPrinter
    'CashDrawerControl113 drawer = jpos.Printer.CashDrawerControl113 New CashDrawer
End

Re: Import Files advice

Posted: Tuesday 6th June 2023 1:58pm
by BruceSteers
AndyGable wrote: Monday 5th June 2023 8:23pm Well after a little bit of googling I have sort of managed to import the libarys into Gambas

But now when I run the program I get the following error

POSPrinterControl113 posprinter = PoSPrinter.POSPrinterControl113 New RecipitPrinter

at the NEW location I get "Not a Object in FMain.class"

Any idea's where to go now guys?
to have 2 objects to the left of that assignment is not valid code

POSPrinterControl113 posprinter =

that's gotta be wrong and probably the error.

Re: Import Files advice

Posted: Tuesday 6th June 2023 2:25pm
by AndyGable
BruceSteers wrote: Tuesday 6th June 2023 1:58pm
AndyGable wrote: Monday 5th June 2023 8:23pm Well after a little bit of googling I have sort of managed to import the libarys into Gambas

But now when I run the program I get the following error

POSPrinterControl113 posprinter = PoSPrinter.POSPrinterControl113 New RecipitPrinter

at the NEW location I get "Not a Object in FMain.class"

Any idea's where to go now guys?
to have 2 objects to the left of that assignment is not valid code

POSPrinterControl113 posprinter =

that's gotta be wrong and probably the error.

ive removed them and tried

Dim PoSPrinterLocal as NEW PoSPrinter.POSPrinterControl113


but it is show me a error saying Unknown identifier 'PoSPrinter'


The JavaPoS works on Windows vb.net and C programming languages and they say it should work for other non Java languages as well