Hardware library

Caravelle

Active Member
Licensed User
Longtime User
A beginner's question. I'm missing a fundamental understanding of how BASIC4PPC works, and I can't find the answer in the Help.

I wrote a small test application directly on the device to try out the example given for hardware.GetStorageCards.

It refused to compile: "hardware1 is not a known control or object. Occurred on line: 10 Hardware1.New1".

I gather from the Help I should have used the Device - Add DLL dialog, so I tried this but it doesn't find any DLLs to Add. Should I transfer a copy of "Hardware.dll" to the device, and if so where should I put it? Any objection to a new "Libraries" folder within the Basic4ppc folder?

Thanks

Caravelle
 

Ariel_Z

Active Member
Licensed User
Did you have a look here: Libraries tutorial? It gives you a deep explanation, but in short:
1. Add the .dll manually on the desktop. If you are using the device IDE, first copy the desired .dll to the Basic4ppc folder.
2. Add an object of the desired type using tools>add object.
3. Before doing anything else with your object, call [object-name].New1 method (or New2 and so on, this differst but usually 1).
4. Then you cans start using it. You know it's been added right if, when you write the object's name and hit the "." (period) sign, a list of available methods appear.
 

Caravelle

Active Member
Licensed User
Longtime User
Thanks, I carried on looking and just found the Tutorial you refer to, where it says:

Exception when working on the device IDE:

Note that libraries are not automatically copied to your device when installing Basic4ppc. Make sure you manually copy all files required for your application to the app folder.

I came back here to say I had the answer, but too late, you got there first. Sorry to have bothered you. :sign0013:

It's true there is lots of help, but it takes a while (and a good memory) to know exactly where to look. Thanks again.

Caravelle
 

Caravelle

Active Member
Licensed User
Longtime User
Hello, me again.

I have enormous difficulty understanding the file system on the iPAQ. I may have installed BASIC4PPC in the wrong folder, I just don't know.

I put it into "iPAQ File Store"/Program Files/" The folder "Basic4ppc" exists there, showing various files, but no dlls at all are shown in File Explorer, I presume they are filtered out for some reason. When I look at the same folder using Windows Mobile File Management on the desktop I can see various dlls in "Caravelle's PDA/iPAQ File Store"/Program Files/" including Hardware.dll, which I just copied in.

And when I open my source file in BASIC4PPC Tools|Add Object is greyed out. But if I click "Compenents" the add dll dialog opens - however it does not list any dlls to add... :BangHead:

I must be doing something wrong...

I would also appreciate some good advice about the best place to install the main program, save sbp files, and place my finished exe files.

Thanks

Caravelle
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The mobile File Explorer filters by default dll files. To show the dlls you should press and hold on an empty section file explorer and check 'Show All Files'.

The file dialog only shows files which are located under \My Documents or any sub folder.
You can create a libraries folder under \My Document and copy all the required libraries from the desktop to this folder.
See this thread for some recommendations when working on a project from both the desktop and the device: http://www.b4x.com/forum/code-samples-tips/38-best-folder-your-source-code.html
 

Caravelle

Active Member
Licensed User
Longtime User
Thanks Erel, but...

I am trying to program directly on the device. I have made a new folder under My Documents called B4P and moved my dll and code file to it. In File Explorer, with "Show all files" checked I can see "Hardware" and "Hwtest" (the code file I am writing that needs to use the Hardware.dll).

I go to Start/Programs/ and I run Basic4ppc. It starts with a default template code. I do File/Open Source and select "HWtest" in folder B4P. My code is then shown. I click Tools. "Add Object" is greyed out. How do I follow Ariel's advice
"Add an object of the desired type using tools>add object"
:BangHead:

As I said before, if I click "Components", the add dll dialog comes up - but it does not show any dlls to add. It also seems rather odd that it has a column for adding dlls to the desktop but I shall try not to think about how that would work :)

Thanks

Caravelle
 

agraham

Expert
Licensed User
Longtime User
The file dialog only shows files which are located under \My Documents or any sub folder.
This only seems true on WM2003 for me. I don't know about WM5 but under WM6 only the contents of \MyDocuments seem to be available not the contents of any sub-folder.

I find the standard open and save dialogs so confusing that I have FileDialogChanger that I referred you to in another post on all my devices.
 

Ariel_Z

Active Member
Licensed User
I assume you have copied the needed .dll's to the device?

About the "Add dll to the desktop" thing, since Basic4ppc allows developing on the desktop and on the device and running 100% identical source code, there sometimes needs to be a difference in the .dll added itself. This column allows you to specify which dll will be used when your code runs on the desktop and which when on the device. For some dll's it's the same dll. When different, the convention is to name the dll XXXDesktop and XXXDevice.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This only seems true on WM2003 for me. I don't know about WM5 but under WM6 only the contents of \MyDocuments seem to be available not the contents of any sub-folder.
Are you sure?
I've just tested it on a WM6 device and files under sub folders do appear. There is even a 'folder' column in the dialog listview.
 

Caravelle

Active Member
Licensed User
Longtime User
Ariel wrote:

I assume you have copied the needed .dll's to the device?

Yes. I wrote:

In File Explorer, with "Show all files" checked I can see "Hardware" and "Hwtest" (the code file I am writing that needs to use the Hardware.dll).

so no-one would ask me that question! :) There are various dlls already in the Basic4ppc program folder and the one I copied over from the desktop (hardware.dll) in the My Documents/B4P folder.

I understand about having different dlls for desktop and device. I just find it amusing that when programming on the device one is invited to add dlls to the desktop, rather than to include a dll in a compiled exe file for the desktop :) Don't worry, it's just the way my mind takes words and phrases literally.

In reply to Erel and agraham on the file dialog issue, the iPAQ214 uses WM6. Are you suggesting that in WM6 the add dll dialog does not show items in sub-folders of My Documents? Or that if dlls are not in the top level of My Documents, the system does not know they exist, so "Add Object" is greyed out?

The brick wall I am facing now is that I cannot add an object because the add object menu item is not available. So what next, please?

Thanks

Caravelle
 
Last edited:

agraham

Expert
Licensed User
Longtime User
Are you sure?
If I do File->Open Source on my iPAQ 214 I don't see any sources in folders under \MyDocuments. The same with trying to add a dll as a component. I think it is because I keep all my sources in folders under a \MyDocuments on my SD card. On my WM2003 Axim X30 this \MyDocuments seems to be merged with the \MyDocuments on the actual device in the dialogs. WM6 doesn't seem to do this, or at least only for the first level content not any folders, so I can see the folders under the internal \MyDocuments but not any under \MyDocuments on the SD card :(

In general on the SD card it looks like the dialogs don't go any deeper than a single folder whereas on the internal storage they do. I find this totally confusing and so use FileDialogChanger instead.
 

Caravelle

Active Member
Licensed User
Longtime User
After much messing around, including a complete re-synchronisation between desktop and device (the device prompted me for this, I have no idea why) I now have the right dll(s) showing in the Tools|Components dialog, the Add Object item is no longer greyed out, and I was able to add the object as "hw". After which the program ran successfully first time :sign0060:

When I click my "Cards" button I get "\SD Card", \"CF Card", "\iPAQ File Store", "Hard Disk" in that order, so long as the relevant item is plugged in.
I can now at last get on with some actual programming! :icon_clap:

Let's hope everything goes to plan next time I need to add a dll while working on the device.

If it helps resolve the issue about WM6 (I doubt it), my dll file and code files are stored in a sub-folder of My Documents on my WM6 device.

Thanks to all who tried to help.

Caravelle
 

Caravelle

Active Member
Licensed User
Longtime User
Ariel_Z wrote:

BTW: did you use the FileDialogChanger Agraham pointed to?

The program I have just written does not use any file dialogs - it's simply the example in the help for hardware.GetStorageCards inside a Button1_click sub. Click the button and you get a series of message boxes telling you what cards are installed.

I can't see any reason to use file dialogs in any part of my project now. The idea is to transfer all files from the CF card/DCIM/100 folder (which never changes with my camera) to a USB stick. I can do everything necessary with the various Files methods, there is no need to manually navigate or to select anything.

I am putting together and testing various subs to perform parts of the process before I put all the parts together. I'm now wondering how to test how much room there is remaining on the USB stick - it's probably easier just to always use the one size of stick and subtract the total number of bytes transferred - a tally can be kept in an ini file on the stick itself as each file is transferred and the remaining space returned to compare with the size of the next file on the CF card. Or the program could prompt me to pick a USB stick size from a drop-down list.

Excuse me, I am working out how to do all this as I write! Bright Idea Alert. Make the first line of the ini file on each USB stick say what size it is. If this file is not found, only then cue for the size to be entered and save as ini file. I think I'll work on a sub to do this next.

Caravelle
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I can't see any reason to use file dialogs in any part of my project now.
FileDialogChanger isn't for use in projects. It changes the default device open and save dialogs to more useful ones for all applications, especially useful for opening and saving source files and adding component librares in the IDE.
 

Caravelle

Active Member
Licensed User
Longtime User
In that case my answer to Ariel_Z should have read "No". I've been too busy asking questions here, playing with BASIC4PPC as it stands and doing all the other things I do!

Caravelle
 
Top