About

This script can be added to DirectoryOpus 4 either as a button or a hotkey and allows you to retrieve a file version (internally, by using the stock C:Version command) and to display the version in a convenient pop-up window.

The script is designed to not use any external tools and has no other requirements than a stock installation of DirectoryOpus 4 and the Workbench stock version of C:Version. The ARexx script works under the assumption that version strings must contain at least a number. This means that if some developer just supplied letters as the version string then this script will fail.

However, the script is excessively documented and is easy to adapt to use a more comprehensive tool that is able to extract an unconventional version string.

Download

How to Install

  1. Extract the archive
  2. Place DOpus4-Version.rexx wherever you see fit (it is tidy, for example, to create an ARexx directory in DOPUS4: and then place your scripts there).
  3. Open DirectoryOpus4 and right-click and go to Project→Configure
  4. On the screen that pops-up, go to Buttons and create a new button somewhere where you see fit.
    1. Give the button a name (Version, for example) and create a new entry.
    2. Set the cycler to ARexx and click the magnifying glass to enter the path to the DOpus4-Version.rexx script.
  5. You do not need to set any flags.
  6. Save and exit and you are done.

How to Use

In DirectoryOpus 4, select any file that is bound to have a version string and click the button you created. You can also select multiple files and the script will process them all one after the other while skipping files that do not have a version string.

Code

DOpus4-Version.rexx
/*
 *  $VER: DOpus4-Version 1.2 (27 Jun 2015) by Wizardry and Steamworks
 *
 *      © 2015 Wizardry and Steamworks
 *
 *  PROGRAMNAME:
 *      DOpus4-Version
 *
 *  FUNCTION:
 *      Shows the version of file(s) in a DOpus4.
 *
 *  USAGE:
 *      ARexx command DOpus4-Version.rexx (from DOpus)
 *
 *  $HISTORY:
 *
 *  27 Jun 2015 : 1.2 : cleanups and fixes
 *  25 Jun 2015 : 1.1 : remove port, copy file, use random, support spaces (thanks @eab:daxb)
 *  17 Jun 2015 : 1.0 : initial release
 *
 */
 
/*------- Configuration Variables (change these to suit your setup) --------*/
VCMD = "C:Version"              /* Where to find the CBM Version command.   */
/*--------------------------------------------------------------------------*/
 
Opus = Address()    /* Get the DOpus address. */
Options RESULTS     /* Request results. */
Address value Opus  /* Use the DOpus address. */
 
Busy On             /* Set the busy pointer. */
 
/* Get all the selected items and check if something is actually selected. */
GetSelectedAll '*'  /* Get all the selected items. */
Items = RESULT
 
/* Normalize, heh... */
Items = Translate(Translate(Items, '/', ' '), ' ', '*')
 
n = Words(Items)    /* Get the number of selected items. */
If n <= 0 Then      /* Check if no items were selected. */
    Do              /* If no items were selected, */
        Busy Off    /* turn off the busy pointer. */
        Exit        /* and terminate. */
    End
 
/* Set the buttons for continue and abort. */
Status 26                   /* Get the value of the Ok button. */
OldOkay = RESULT
Status 26 set 'Continue'    /* Set the value of the button to continue. */
Status 27                   /* Get the value of the Cancel button. */
OldCancel = RESULT
Status 27 set 'Abort'       /* Set the value of the button to abort. */
 
/* Loop through the selected items and display their name and version. */
Do i = 1 To n                                   /* For all selected entries... */
    Name = Translate(Word(Items, i), ' ', '/')  /* Get the name of the entry and translate back. */
    ScrollToShow Name                           /* Scroll to the entry. */
    Status 13 i + 1                             /* Get the path to the entry. */
    Path = RESULT
    /* Generate temporary files. */
    FTMP = wasRandomHexString(Time(SECONDS), Length(Name))
    Address COMMAND "Copy >NIL:" '"'Path||Name'"' "T:"FTMP
    VTMP = wasRandomHexString(Time(SECONDS), Length(Name))
    Address COMMAND VCMD "T:"FTMP " > " "T:"VTMP
    Address COMMAND "Delete >NIL:" "T:"FTMP 'QUIET FORCE'
    /* Attempt to open the temporary file for reading. */
    If Open('output', "T:"VTMP, 'READ') ~= 1 Then
        Do                                      /* If the temporary file could not be opened, */
            Call wasDOpus4DeselectEntry(Name)   /* deselect the entry, */
            Iterate i                           /* and continue. */
        End
    Tmp = ReadLN('output')                      /* Get the output from the temporary file. */
    Close('output')                             /* Close the file. */
    Version = Word(Tmp, 2)                      /* Split the name into a name and a library version. */
    /* The assumption is that version strings must contain digits. */
    If wasStringContainsDigits(Version) ~= 1 Then   /* Check whether the version string contains digits. */
        Do                                          /* If the version string does not contain digits, */
            Call wasDOpus4DeselectEntry(Name)       /* deselect the entry, */
            Iterate i                               /* and continue. */
        End
    Select                                          /* Switch on i */
        When i = n Then Notify Name " " Version    /* When only one item remains selected just notify. */
        Otherwise                                   /* Otherwise, present a chooser whether to continue or abort. */
            Do
                Request Name " " Version                    /* Show the version. */
                CarryOn = RESULT                            /* Get continue or abort. */
                If CarryOn ~= 1 Then                        /* Check which button was pressed. */
                    Do                                      /* If the abort button was pressed then */
                        Call wasDOpus4DeselectEntry(Name)   /* deselect the entry, */
                        Leave                               /* and abort. */
                    End
            End
    End
    Address COMMAND "Delete >NIL:" "T:"VTMP 'QUIET FORCE'   /* Delete the temporary file. */
    Call wasDOpus4DeselectEntry(Name)                       /* Deselect the entry. */
End
 
/* Restore the continue and abort buttons. */
Status 26 set OldOkay
Status 27 set OldCancel
 
Busy Off    /* Turn off the busy pointer. */
Exit        /* Terminate. */
 
/*************************************************************************/
/*    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    */
/*************************************************************************/
wasDOpus4DeselectEntry: procedure   /* Deselect a selected entry. */
    Parse ARG Item
 
    GetAll '*'
    AllItems = RESULT
    AllItems = Translate(Translate(AllItems, '/', ' '), ' ', '*')
 
    n = Words(AllItems)
 
    Do i = 1 To n
        If Item = Translate(Word(AllItems, i), ' ', '/') Then
            Do
                SelectEntry i - 1 ||' '|| 0 ||' '|| 1
                Return
            End
    End
 
Return
 
/*************************************************************************/
/*    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    */
/*************************************************************************/
wasStringContainsDigits: procedure /* True if string contains digits. */
    Parse ARG String
    Do i = 0 To 9
        If Pos(i, String) ~= 0 Then
            Return 1
    End
Return 0
 
/*************************************************************************/
/*    Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3    */
/*************************************************************************/
wasRandomHexString: procedure /* Generates a random hexadecimal string.  */
    Parse ARG Seed,Size
    If Size = 0 Then Return ''
    Random = Random(0, 15, Size + Seed)
Return D2X(Random)||wasRandomHexString(Random, Size - 1)

amiga/directoryopus/4/get_file_version.txt · Last modified: 2022/04/19 08:28 by 127.0.0.1

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.