Home Forums HTBasic Forum Help with using HTBFileopen.dll, please!

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #7440
    Peter M
    Participant

      I am working with HTBasic 10.1.2

      I have an HTBasic application which reads data from files of previously logged data and re-analyses it.
      The files have an extension .cal
      Multiple files are selected in HTBFileopen.dll.

      That at least is the aim!

      The Readme.doc file whch accompanies HTBFileopen.dll in the DLL Toolkit tree lists 4 parameters to control HTBFileopn.dll.
      These are:

      1. A string name to receive the returned filenames
      2. A default filename extension
      3. The initial filename to appear in the filename edit box
      4. Bit flags which initialise the dialod box behaviour

      Now in practice there seem to be other parameters which are not documented but which seem essential to the operation of HTBFileopen.dll.
      These can be seen in the program Filedialogtest.prg in the DLL Toolkit tree.

      Firstly, it seems necessary to open a path to a buffer for transfer of the selected filename(s) to the string. The buffer pathname is passed to Fileopen.dll as paramater 1.
      Parameter 2 is now the string name for the returned filename(s).
      There follow three more parameters related to displayed files and extensions, before the final parameter, parameter 6, which passes the bit flags.

      The correct parameter list seems to be:

      1. A buffer pathname for transfer of the string of file names
      2. A string name to receive the returned filenames
      3. ?
      4. ?
      5. ?
      6. Bit flags which initialise the dialod box behaviour

      Now, passing this 6-parameter string to the HTBFileopen.dll seems to work OK.

      The residual problem with which I would like some help is in undertsanding the 3rd, 4th and 5th parameters. I have been unable, so far, to coax these parameters into restricting the list of files available for selection to include only those with an extension defined by a parameter. That is to say I can not limit the list of selectable files to include only those with a .cal extension.

      Please let me know if I am missing some documentation which may help me, or please advise me how to use the three filenmae and extension related parameters.

      Thank you in advance for your help with this enquiry.

      #7441
      ZeRider
      Participant

        An alternative solution would be to use the “FILE WIDGET” or the “DIALOG FILE” from Basic Plus (BPLUS) but there’re adapted for manual file choice.
        For a file choice by software the CAT function could be use

        #7442
        Peter M
        Participant

          Thank yyou for suggesting the FILE WIDGET and DIALOG.
          I’ve tested these again – it’s a few years since I did so.

          There seem to be two shortomings with these in my application, if I have understood them correctly.

          1. I can’t find a way to select multiple files so I can initiate a batch process.
          As I see it, I would have to select and load files one at a time before commencing the batch process.
          HTBFileopen.dll does allow multiple selections and simply concatenates them into the string which it returns.
          2. I haven’t been able to find a way to customise the contents of the file type selection box.

          If either or both of these can be achieved then this would indeed be a rather nicer solution than the dll.

          Thank you again.

          #7443
          ZeRider
          Participant

            CAT instructions could be very useful to put all the files selected with your criteria in a list :

            Nb_file=0
            Directory$=”D:\Calibration Measurement”
            CAT Directory$;NAMES,COUNT Nb_file
            !
            ALLOCATE Catalog$(1:Nb_file)[80]
            Selection$=”*.Cal”
            !
            CAT Directory$ TO Catalog$(*);SELECT Selection$,COUNT Nb_file,NAMES
            !
            FOR I=1 TO Nb_file
            PRINT I,Catalog$(I)
            NEXT I
            !
            PRINT
            PRINT “Nb File=”;Nb_file
            !
            END

            #7462
            Henrikhuse
            Participant

              Hi, had the same problem and received the enclosed documentation with some additions and corrections from TransEra. Hope that might help

              HTBfileopen.DLL

              DLL LOAD “HTBfileopen”

              DLL GET “VOID HTBfileopen:Fo”
              DLL GET “VOID HTBfileopen:Sa”

              Fileopen( )

              This function brings a File Open Dialog Box on screen and returns a string with the opened file and pathname. This function takes 6 parameters.

              Parameter 1
              Basic Type: BUFFER
              C Type: void *

              This parameter is a buffer that will contain the returned file name(s). Make sure the buffer is dimensioned large enough to hold all returned file names.

              Parameter 2
              Basic Type: STRING
              C Type: char *

              This parameter is actually the return value, so passed in it must be a HTBasic STRING Dimensioned to be large enough to hold the file name and path.

              Parameter 3
              Basic Type : STRING
              C Type: char *

              This parameter is the default filename extension.

              Parameter 4
              Basic Type : STRING
              C Type: char *

              The initial filename that appears in the filename edit box..

              Parameter 5
              Basic Type : STRING
              C Type: char *

              File extension filters.

              Parameter 6
              Basic Type : LONG
              C Type: long

              A set of bit flags you can use to initialize the dialog box. The value of the parameter is the sum of the values of the styles. The styles associated with the values can be seen below in the styles table.

              Saveas( )

              This function brings a SaveAs Dialog Box on screen and returns a string with the opened file and pathname. This function takes 5 parameters.

              Parameter 1
              Basic Type: STRING
              C Type: char *

              This parameter is actually the return value, so passed in it must be a HTBasic STRING Dimensioned to be large enough to hold the file name and path.

              Parameter 2
              Basic Type : STRING
              C Type: char *

              This parameter is the default filename extension.

              Parameter 3
              Basic Type : STRING
              C Type: char *

              The initial filename that appears in the filename edit box..

              Parameter 4
              Basic Type : STRING
              C Type: char *

              File extension filters.

              Parameter 5
              Basic Type : LONG
              C Type: long

              A set of bit flags you can use to initialize the dialog box. The value of the parameter is the sum of the values of the styles. The styles associated with the values can be seen below in the styles table.

              STYLES:

              Value Attribute
              1 Causes the Read Only check box to be checked initially when the dialog box is created. This flag indicates the state of the Read Only check box when the dialog box is closed.
              2 Causes the Save As dialog box to generate a message box if the selected file already exists. The user must confirm whether to overwrite the file.
              4 Hides the Read Only check box.
              8 Restores the current directory to its original value if the user changed the directory while searching for files.
              16 Causes the dialog box to display the Help button.
              32 Enables the hook function.
              64 Indicates that the Template member points to the name of a dialog template resource in the module identified by the Instance member.
              128 Indicates that the Instance member identifies a data block that contains a preloaded dialog box template. The system ignores the Template Name if this flag is specified.
              256 Specifies that the common dialog boxes allow invalid characters in the returned filename. Typically, the calling application uses a hook procedure that checks the filename by using the FILEOKSTRING message. If the text box in the edit control is empty or contains nothing but spaces, the lists of files and directories are updated.
              512 Specifies that the File Name list box allows multiple selections.
              1024 Specifies that the user typed a filename extension that differs from the extension specified by Parameter 1 in the Fo or Sa function call.
              2048 Specifies that the user can type only valid paths and filenames. If this flag is used and the user types an invalid path and filename in the File Name entry field, the dialog box function displays a warning in a message box.
              4096 Specifies that the user can type only names of existing files in the File Name entry field. If this flag is specified and the user enters an invalid name, the dialog box procedure displays a warning in a message box.
              8192 If the user specifies a file that does not exist, this flag causes the dialog box to prompt the user for permission to create the file. If the user chooses to create the file, the dialog box closes and the function returns the specified name; otherwise, the dialog box remains open.
              16384 Specifies that if a call to the function fails because of a network sharing violation, the error is ignored and the dialog box returns the selected filename.
              32768 Specifies that the returned file does not have the Read Only check box checked and is not in a write-protected directory.
              65536 Specifies that the file is not created before the dialog box is closed. This flag should be specified if the application saves the file on a create-nonmodify network share. When an application specifies this flag, the library does not check for write protection, a full disk, an open drive door, or network protection. Applications using this flag must perform file operations carefully, because a file cannot be reopened once it is closed.
              131072 Hides and disables the Network button.
              262144 For old-style dialog boxes, this flag causes the dialog box to use short filenames.
              524288 Indicates that any customizations made to the Open or Save As dialog box use the new Explorer-style customization methods.
              1048576 Directs the dialog box to return the path and filename of the selected shortcut (.LNK) file. If this value is not given, the dialog box returns the path and filename of the file referenced by the shortcut.
              2097152 For old-style dialog boxes, this flag causes the dialog box to use long filenames.
              8388608 Windows NT 5.0, Windows 98: Enables the Explorer-style dialog box to be resized using either the mouse or the keyboard. By default, the Explorer-style Open and Save As dialog boxes allow the dialog box to be resized regardless of whether this flag is set. This flag is necessary only if you provide a hook procedure or custom template. The old-style dialog box does not permit resizing.

              #7463
              Peter M
              Participant

                Thank you, Henrikhuse, for a most helpful reply to my post.
                You have clarified what Parameter 3 and Parameter 5 should do.
                In practice, they are not working quite as I expected.

                To re-cap my post, I would like to have a file open dialog which allows multiple file selection (which Fileopen.dll does with style=512), and where I can set a mask so only the selected extensions are shown in the file list.

                With Fileopen.dll, what I expect to see, when I open the file open dialog (based on the comprehensive documentation in your post) is that all file extensions are masked out except those permitted by Parameter 3 or selected from the option(s) in the extension list box set by parameter 5. In practice, neither Parameter 3 nor 5 seem to influence the list of selectable files. (The Parameter 5 list box seems ineffective and is greyed out, perhaps because it only contains one item. I have not been able work out a format for Parameter 5 to display a list of extensions in the box from which to select.) It may simpply be that, as I don’t know any C, I am not using the correct syntax for these parameters – in which case advice would be much appreciated!

                What I find is that I can only mask down the file list to show the preferred extension by passing *.extension as parameter 4.

                I also find that I can only set one filename in parameter 4 (Style 512 does not influence Parameter 4) and so I can not mask the file list to show files with either of two defined extensions, which would be a rather useful option.

                I can use the Fileopen dll in my application – it is still better than the Widget alternative in that it supports multiple file selection – but it would be much more elegant if I could gain more control of the extension masking in the file list.

                Thank you again for your help, and thanks to to all who replied earler to this post.

                #7482
                Rob Walker
                Participant

                  Slightly tangential to this thread (for which apologies) but still relevant I think: Has anyone tried to use the HTBfileopen DLL with the new demo version HTB 2021? I have, and found it doesn’t work at all. It just produces ERROR 1100 at the DLL LOAD statement. I have raised a support ticket on this issue. I have tried other DLL Toolkit examples (as provided) and found HTBbuttons also fails. There may be others, but some DO work so it’s not that the DLL feature has been blocked for the Demo or anything of that sort.

                  #7483
                  Peter M
                  Participant

                    A follow-up to Rob’s post – I tried the HTBFileopen DLL from the 2021 demo with HTB version 10 and it seemed to work there, with just the same characteristics as that originally packaged with version 10. Hence I doubt if the dll has changed during the upgrade from 10 to 2021.

                    I hope this helps.

                    #7484
                    Rob Walker
                    Participant

                      Thanks Peter M. Yes, I tried that too, and agree. The problem is not with the DLL as such but with the HTB 2021 installation. Of course you have to keep changing the MSI Folder Path for the examples to run. DLLs RadioButton, CheckButton, Buttons and Cursor also fail. The ones involving message boxes tend to work. Because FileOpen is one of the first things encountered, I haven’t got far enough with HTB 2021 to find other run-time issues, but I have noticed that the FIND feature in the editor seems to be messed-up; highlighted text is not automatically placed in the search-box (which seems to be pre-filled with garbage).

                      #7499
                      Ralph Wilson
                      Keymaster

                        HTBFileopen DLL problem solved!

                        One of the recent changes made to HTBasic 2021 was changing the name of the executable from HTBwin.exe to HTBasic.exe (to make it more obviously the main executable). However, it turns out that some of the DLLs in the library, including HTBFileopen.dll, reference HTBwin.exe.

                        So, a new release will be issued next week that changes the installation name back to HTBwin.exe. But as a temporary workaround, you can verify that renaming HTBasic.exe in the install folder back to HTBwin.exe fixes this problem. Obviously, it was not anticipated that simply changing the name of the main executable could have this affect, but at least it’s a simple fix.

                        #8774
                        Anonymous

                          The issue is with the HTB 2021 installation rather than the DLL.
                          magento 2 development services

                        Viewing 11 posts - 1 through 11 (of 11 total)
                        • You must be logged in to reply to this topic.
                        Scroll to Top
                        HTB icon

                        Please Sign In