+ Reply to Thread
Page 12 of 13 FirstFirst ... 210111213 LastLast
Results 111 to 120 of 122

Thread: Subcode.vdm : The Macro Subroutines Project

  1. #111
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter,

    Thank you for catching that. Fixed the copy in the zip file.

    Scott
    Last edited by Scott Lambert; November 3rd, 2016 at 07:50 AM.
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  2. #112
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Quote Originally Posted by Scott Lambert View Post
    Hi Peter,

    Thank you for catching that. Fixed the copy in the zip file.

    Scott
    H Scott,

    You are welcome.

    Now, I am ready to study your get file attributes subcode. Well, not quite, I am only interested in the Archive attribute only. I tried to isolate it. Here it is;

    if(#30>=32) {
    #30=#30-32
    #23=1 // archive
    reg_set(20," A",append)
    }


    Do I understand it correctly? I have the divedie the value of the file attribute by 32. If the remainder is 1 then the file is an Archive file.
    In other case no action.

    My problem is that I see no reference to remainder.

    -peter

  3. #113
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter,

    "Do I understand it correctly? I have the divedie the value of the file attribute by 32. If the remainder is 1 then the file is an Archive file. In other case no action."

    That quick method of dividing only works for read-only. I would suggest just using the subcode getatttr and then testing if #23 = 0 or 1 for the archive attribute.

    Scott

    Scott
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  4. #114
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi,

    Using what I learned about the logical and operator, I have rewritten several subroutines.

    Binary now works for ANY number between 0 and max_num.

    isdir and getattr have both been rewriiten to use the logical and operator to perform their function.

    Scott
    Attached Files Attached Files
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  5. #115
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311

    A big thank you.

    Quote Originally Posted by Scott Lambert View Post
    Hi Peter,

    "Do I understand it correctly? I have the divedie the value of the file attribute by 32. If the remainder is 1 then the file is an Archive file. In other case no action."

    That quick method of dividing only works for read-only. I would suggest just using the subcode getatttr and then testing if #23 = 0 or 1 for the archive attribute.

    Scott

    Scott
    Hi,

    A belated big thank you for pointing out that the "dividing and finding the remainder" method for finding the file attribute only works for the read only attribute special case. This is certainly a subtle point, since the procedure does work in the general case, but it fails to give the right answer.

    I went back to the on-line Vedit Macro Language manual and studied the description of the File_Attribute command.
    It gives an elaborate description of the various attribute parameters, via the Mask_i parameters. My problem was that I do not know the definition of the mask parameters.

    Studying your e-mails I came up with the following definition: The Mask_i parameter for a given positive number N is the coefficient of 2^i in the binary expansion of N. I have a hunch that computer scientists refer to this number as the i-th bit of N.

    Having said this, it is easy to check the cool formula,

    Mask_i(N) = N & i, for i=0,1,2,4,8,..

    Here of course, Mask_i(N) is the Mask_i parameter of N and & is the Bitwise AND operator of Appendix C of the Vedit Macro Language Manual.


    I wonder where does the formula come from. I have a vague recollection that I have learned it from Pauli, but could not find the reference. So, if Pauli would help me out, I would appreciate it.


    Thanks for everything,

    -peter
    Last edited by rejto12; December 13th, 2017 at 01:16 PM.

  6. #116
    Quote Originally Posted by rejto12 View Post
    Hi,
    Studying your e-mails I came up with the following definition: The Mask_i parameter for a given positive number N is the coefficient of 2^i in the binary expansion of N. I have a hunch that computer scientists refer to this number as the i-th bit of N.

    Having said this, it is easy to check the cool formula,

    Mask_i(N) = N & i, for i=0,1,2,4,8,..

    Here of course, Mask_i(N) is the Mask_i parameter of N and & is the Bitwise AND operator of Appendix C of the Vedit Macro Language Manual.


    I wonder where does the formula come from. I have a vague recollection that I have learned it from Pauli, but could not find the reference. So, if Pauli would help me out, I would appreciate it.
    -peter
    There is no such thing as "Mask_i parameter". The term mask or bitmask is used to refer a value that is used to separate specific bit(s) from a numeric value using AND operation.

    For example, to extract the lowest bit from, use bitmask 1 (binary 00000000000000000000000000000001).
    To extract 2nd lowest bit, use bitmask 2 (binary 00000000000000000000000000000010).
    To extract 3rd lowest bit, use bitmask 4 (binary 00000000000000000000000000000100), etc.

    For example, the bitmask for Archive attribute is 32. To check if Archive attribute is set on current file, use something like:
    Code:
    #1 = File_Attrib(PATHNAME)
    if (#1 & 32) {
        Statline_Message("Archive attribute is set")
    } else {
        Statline_Message("Archive attribute is not set")
    }
    There is no formula. It is just how the numeric values are stored in computer memory.
    Pauli -- Using Vedit 6.24.2 on Windows 7 Enterprise (64 bit) and on Windows 10 (64 bit)

  7. #117
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Thanks Pauli,

    I take your code reference refers to a program of yours. May I have that reference too.

    Thanks again.

    -peter

  8. #118
    The code does not refer to any program. You can copy and execute the code example as it is. It displays whether or not Archive attribute is on in the file you have currently open.
    For more information of file attributes, search for FileAttrib in Vedit Help index.
    Pauli -- Using Vedit 6.24.2 on Windows 7 Enterprise (64 bit) and on Windows 10 (64 bit)

  9. #119
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Quote Originally Posted by pal View Post
    The code does not refer to any program. You can copy and execute the code example as it is. It displays whether or not Archive attribute is on in the file you have currently open.
    For more information of file attributes, search for FileAttrib in Vedit Help index.

    Thanks Pauli,

    I did follow up your Vedit Help index reference. This is that I found:

    ---------------------------------------------------------------------------
    File_Attrib("file")

    Return the specified file's attributes (read-only, hidden, etc.)

    Windows (and DOS) define the attributes as:

    Mask 1

    Read-only

    Mask 2

    Hidden

    Mask 4

    System

    Mask 8

    Volume label

    Mask 16

    Directory

    Mask 32

    Archive

    Return -1 if 'file' does not exist.
    ---------------------------------------------------------------------------------------------------

    So, based on the above and based on my previous Lambert-Lindgren tutoring I gleaned the following definition for my personal use:
    ------------------------------------------------------------------------------------------------------------------------------
    DEFINITION: We say that the Archive attribute of a given file, say "file" , is set if:

    File_Attribute("file")&32 =1

    ------------------------------------------------------------------------------------------------------------------------------


    Also, a belated thank you to Ted, for implementing the " bitwise and " operation in Vedit. Otherwise the left side of my formula would not make any sense.

    Incidentally, I have been looking at Scientific Calculators and I have been unable to find he "bitwise and" operation. Am I missing something?

    Thanks again,

    -peter
    Last edited by rejto12; January 31st, 2018 at 05:20 PM.

  10. #120

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts