/* * $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)