Search found 1008 matches

by phspaelti
2019-10-02 05:57:20
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

$my1997keys = Array.new() foreach $key, value in $myhash if $value.find('1997') $my1997keys.push $key end end Pulling these keys into an Array may be useful, if you want to process them further, perhaps repeatedly. But since you will most likely need to loop through them again to do anything, you c...
by phspaelti
2019-10-02 04:41:18
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

If the hash sample you are giving us is representative you could achieve this with code like the following, which is just a variant of the code I provided earlier for creating a reverse hash. $subhash = Hash.new() foreach $key, $value in $myhash if $value.find('1997') $subhash{$key} = $value end end...
by phspaelti
2019-09-29 04:55:49
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

But how can I retrieve the key if I know the value? A hash is a one-way function. So, you cannot do that. In fact since many keys may map to the same value, it may be physically impossible to "reverse the hash". If you did want to do that you would have to use a foreach loop and loop over the keys ...
by phspaelti
2019-09-27 22:02:24
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

To get the binary forms I use a hash, and that is also why I copy its results with the clipboard to make use of it in the actual macro manipulating them. (Or is there a better way to make use of the output of one macro in another macro?) The best way to pass such info between macros is to use a Reg...
by phspaelti
2019-09-27 09:28:39
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

Well, yes. Once you write out the array in the form '("1", "2", "3", "4", "5")' on the clipboard then it stops being an array, and now it's just a piece of text. So then you couldn't use the command .appendValuesFromArray . It's important to understand that internally an array is a complicated struc...
by phspaelti
2019-09-27 07:57:58
Forum: Nisus Writer Pro Macros
Topic: Turning an integer into an array of its digits
Replies: 15
Views: 890

Re: Turning an integer into an array of its digits

If you want to add the digits from $list into $arr you can use: $arr = Array.new $arr.appendValuesFromArray $list But $list is already an array. So the only reason to do this is if you want to combine several arrays together. And as you can see from your own experiment, Nisus arrays can themselves h...
by phspaelti
2019-09-09 16:03:38
Forum: Nisus Writer Pro Macros
Topic: Find/replace in each paragraph of the selection
Replies: 10
Views: 908

Re: Find/replace in each paragraph of the selection

1. Find in Selection - Method 1. I'm afraid I don't understand your hint. Could you please give a worked out example? Find '^.+?\t\d+', 'Eas' $results = $doc.textSelections … … I just needed to modify a bit the syntax since the Selection object doesn't have a .range property: Sorry about that. Actu...
by phspaelti
2019-09-09 04:47:09
Forum: Nisus Writer Pro Macros
Topic: Find/replace in each paragraph of the selection
Replies: 10
Views: 908

Re: Find/replace in each paragraph of the selection

Ah, yes, these are good questions. 1. Find in Selection The macro command .find can unfortunately not be limited to a selection, the way the menu command can. There are a couple of ways to work around this. Method 1: You can do the initial find using the menu command "Find in Selection" and then use...
by phspaelti
2019-09-08 17:13:40
Forum: Nisus Writer Pro Macros
Topic: Find/replace in each paragraph of the selection
Replies: 10
Views: 908

Re: Find/replace in each paragraph of the selection

Now for the second point: … the macro should check user input against the number at the end of each line). In the previous code, the "found bit" is in the $result.subtext . Since you will want the number to check against, how to do that? The trick is another clever feature of the macro language find...
by phspaelti
2019-09-08 16:39:30
Forum: Nisus Writer Pro Macros
Topic: Find/replace in each paragraph of the selection
Replies: 10
Views: 908

Re: Find/replace in each paragraph of the selection

Okay then. First, if you want to allow for variable pre/post you can do this like this: $pre = '<pre>' $post = '<post>' Find And Replace '^.+?\t\d+', $pre &'\0' & $post, 'Ea' Now let's consider how we can do find/replace in the macro language. Find and Replace is an operation on text, so you need a ...
by phspaelti
2019-09-08 14:44:23
Forum: Nisus Writer Pro Macros
Topic: Find/replace in each paragraph of the selection
Replies: 10
Views: 908

Re: Find/replace in each paragraph of the selection

Hello JohSeb, Let me first ask, is there a particular reason why you are trying to do this with a macro? You can accomplish exactly this with Find/Replace directly, and you can also just macroize the Find/Replace expression. That should look something like this: Find And Replace '^.+?\t\d+',"Pre \\0...
by phspaelti
2019-09-01 22:48:34
Forum: Nisus Writer Pro
Topic: Table Format for Sort by date?
Replies: 31
Views: 3564

Re: Table Format for Sort by date?

Hello again feathers, Nice job with all that testing! Here is an updated version with the ascending/descending feature added: Sort Table Rows By Selected Date Column.nwm As to the other points: I'm not sure what's going on with blank cells for you. For me blank cells sort at the end, or at the begin...
by phspaelti
2019-08-31 17:16:50
Forum: Nisus Writer Pro
Topic: Table Format for Sort by date?
Replies: 31
Views: 3564

Re: Table Format for Sort by date?

…but just report now that the one that's interesting me most at the moment is the one that sorts the table in one go, which will be trickiest I expect. (ie. "Sort Table Rows By Selected Date Column".) On my first tests it threw an error, and I'll just ask if it's capable of handling a table with a ...
by phspaelti
2019-08-30 21:41:03
Forum: Nisus Writer Pro
Topic: Table Format for Sort by date?
Replies: 31
Views: 3564

Re: Table Format for Sort by date?

Now that the issue of ordinal dates has been raised, it's not enough to strip out the ordinal suffixes when converting to ISO format. You probably want to (re)instate them when doing the inverse operation. Except of course that once you have converted them you won't know if the original dates had o...
by phspaelti
2019-08-30 19:06:46
Forum: Nisus Writer Pro
Topic: Table Format for Sort by date?
Replies: 31
Views: 3564

Re: Table Format for Sort by date?

So, what are the "other drawbacks" that you speak of for this one? Since Adrian's macro uses Find/Replace it affects only the date parts of your selection, and leaves the rest intact. The macro I provided will, if given a selection that contains non-date parts, might end up deleting/overwriting tho...