View Full Version : Needs an enhancement of the hex-bin.vdm Vedit distribution macro.

rejto12

November 5th, 2016, 01:21 PM

Hi,

I understand that this is the macro that implements the Vedit menu command {Edit,Convert, Hex to binary}.

Now, I would like to have an enhancement that would convert for example the hexadecimal number 2 , that is to say the decimal number 2x16 = 32, into a binary number. I guess, this would be 32=2^5 decimal and so, 10000 bin

Thanks as always,

-peter

Scott Lambert

November 6th, 2016, 08:35 AM

Hi Peter

"Now, I would like to have an enhancement that would convert for example the hexadecimal number 2 , that is to say the decimal number 2x16 = 32, into a binary number. I guess, this would be 32=2^5 decimal and so, 10000 bin"

Not quite sure what you are saying there, however....

If you wish to convert a decimal number to binary, set #10 to the number and do:

call_file(99,"subcode.vdm",binary")

The result will be stored in t-reg 20

If you wish to convert a hex number to binary, set t-reg 10 to the hex number and do:

reg_set(10,"0x",insert) // add the 0x in front of hex number

#10=num_eval_reg(10)

call_file(99,"subcode.vdm","binary")

Binary result in t-reg 20

Both will work for numbers upto (2^17)-1 decimal.

Scott

rejto12

November 6th, 2016, 12:32 PM

Scott said,

"Not quite sure what you are saying there, however...."

So, let me backtrack to my message # 1.

I understand that this is the macro that implements the Vedit menu command {Edit,Convert, Hex to binary}.

Now, I would like to have an enhancement that would convert for example the hexadecimal number 2 , that is to say the decimal number 2x16 = 32, into a binary number. I guess, this would be 32=2^5 decimal and so, 10000 bin

I would like to replace the Vedit distribution macro hex-bin.vdm by another hypothetical macro that I call hex-bin_enhanced.vdm.

I have 3 requirements on the hypothetical hex-bin.vdm

1.: It should have a fancy graphycal "interface" , lke the one listed in your Subcode.vdm.

2.: There should be an original button on the interface. This button should call the original hex-bin_orig.vdm

3.: There should be a converting hexadecimal numbers to binary numbers button.

(This should call your conversion subroutine , that you have just sent me. Incidentally, a big thank you for it)

OOPs, so far I do not need an enhanced hex-bin_enhanced.vdm.

4.: I would like to integrate this macro into the Vedit Menu system. Specifically, I would like to call this macro from the {Edit, Convert, Hex to binary} Vedit menu command.

I think item 4.: is the rub. I have a hunch that I coined the word Vedit Menu command. In this case {Edit, Convert, Hex to binary} is the

command on the Vedit menu, which invokes the hex-bin.vdm macro. I also looked up Chapter 6 of the Vedit Manual which describes the

Vedit Menu . I no longer remember the exact words.

I also vaguely remember that in one of your latex macros that you have written for me you gave me a fancy interface where I do have the option of coping a latex command with a backslash. The default is to copy it without a backslash. I have a hunch that this is similar to the present situation.

In short, the default option would call the original Vedit distribution macro and the enhanced option would call your subroutine.

Thanks, as always.

-peter

Scott Lambert

November 7th, 2016, 08:56 AM

Hi Peter,

Attached is BinCalc.vdm which will convert a decimal or hex number into binary. Just enter a number and press either "Decimal to Binary" or "Hex to Binary". Option to put result in Windows Clipboard, so you may paste it somewhere.

The "Org Hex-Bin" button requires the file hex-bin-org.vdm to exist in order to work, but is easy to change in the code.

So to make this work with {Edit, Convert, Hex to binary}, I think you would:

1. rename hex-bin.vdm to hex-bin-org.vdm

2. rename Bincalc.vdm to hex-bin.vdm

Scott

rejto12

November 7th, 2016, 12:29 PM

Hi Peter,

Attached is BinCalc.vdm which will convert a decimal or hex number into binary. Just enter a number and press either "Decimal to Binary" or "Hex to Binary". Option to put result in Windows Clipboard, so you may paste it somewhere.

The "Org Hex-Bin" button requires the file hex-bin-org.vdm to exist in order to work, but is easy to change in the code.

So to make this work with {Edit, Convert, Hex to binary}, I think you would:

1. rename hex-bin.vdm to hex-bin-org.vdm

2. rename Bincalc.vdm to hex-bin.vdm

Scott

Great,

Thank you very much. I shall try it out, right away and report back to you.

-peter

rejto12

November 7th, 2016, 02:31 PM

Hi Peter,

Attached is BinCalc.vdm which will convert a decimal or hex number into binary. Just enter a number and press either "Decimal to Binary" or "Hex to Binary". Option to put result in Windows Clipboard, so you may paste it somewhere.

The "Org Hex-Bin" button requires the file hex-bin-org.vdm to exist in order to work, but is easy to change in the code.

So to make this work with {Edit, Convert, Hex to binary}, I think you would:

1. rename hex-bin.vdm to hex-bin-org.vdm

2. rename Bincalc.vdm to hex-bin.vdm

Scott

Hi,

It works, essentially, like a charm

Experiment 1.:

I saved your BinCalc.vdm, under the same name, into my USER_MAC directory. I only wanted to test the "new part".

a. I launched it via the {Misc, Load exec user macro.., } Vedit Menu Command. It worked, provided that I was in my USER_MAC directory.

b. I opened up BinCalc.vdm in Vedit. Then I launched it via {Misc, Exec, Current Buffer }. I needed the same condition.

Thanks again,

-peter

Powered by vBulletin® Version 4.1.7 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.