Hi
My attempt using the Hardware library failed so I've taken the example out of the help manual, added Form1 and the DLL's (Hardware.dll for device and HardwareDesktop.dll for PC) but trying to run I still get the same error:
An error occured on sub main.app_start.
Line number:10
Hardware1.New1
Error description:
Object reference not set to an instance of an object.
I'm using the Desktop Version 6.9 with .Net 2.0.50727.3603:sign0085:
You may have guessed I'm new to Basic4pp, the help manual used Hardware1.New1 but the syntax did not change so I've tried Hardware.New1 as below. I'm now getting the colour change and options following the '.' but noticed the Objects (hardware) are not showing up in the right hand side box.
Have closed down & restarted and cut code down to below and still getting same error ?
and yes added the Hardware.dll & HardwareDesktop.dll in tools Components
'Add a Hardware object named Hardware1
Sub Globals
End Sub
Sub App_Start
Form1.show
Hardware.New1
Msgbox("Device ID: " & Hardware.GetDeviceID)
End Sub
Sub Timer1_Tick
Hardware.KeepAlive 'Resets the system idle timers
End Sub
As corwin42 pointed out just minutes before you posted, you have to name the object in the IDE as well as doing the Hardware1.New1. The former is a compile-time operation and will cause the object name to appear in the right-hand pane. You could think of it as a declaration that associates the name with the object type in the library. The Hardware1.New1 is a run-time process and could happen zero or more times in any run of the program (depending upon the design).
Many thanks - penny slowly dropping, I'd assumed once you add the component it created an instance
Just a note for any other beginners after adding the components you also need to create the object via Tools > Add Object and select Hardware (or what ever component your using) and give it a name ie Hardware1
In programing for any languages it's the same thing C C++ VB .NET and on B4PPC... Else we can't use a library function if we don't know with what we use... (Sorry if you don't understand lol)
Many thanks - penny slowly dropping, I'd assumed once you add the component it created an instance
Just a note for any other beginners after adding the components you also need to create the object via Tools > Add Object and select Hardware (or what ever component your using) and give it a name ie Hardware1