how to edit stream of data in Microsoft Word - ms-word

My data in MSword looks like this,"C0 00 00 FE 08 FF FB FF"
I want to add 0x and it should be comma separated ,so the final format will look like "0xC0,0x00,0x00,0xFE,0x08,0xFF".How can i make it in the required format in Microsoft Word?Currently I am doing it manually.

The simplest way to deal with it is using Find and Replace and manually replace only the first one.
Steps:
1. Select the text as shown below:
2. Press Ctrl+ H to open this window:
3. Enter Space character in "Find what" and ,0x in "Replace with".
4. Click on "Replace All" to get this:
Click "Yes" or "No" according to your preference. For this case, I clicked No.
5. Manually adjust the first one to 0xC0.
In this way, you would have to adjust the first one manually and the rest will be taken care of by Find and Replace.

Related

FileMaker auto-generate buttons and fields for all/some fields of the record?

I'm writing a data-sync/merge solution in FileMaker where I have two data sources and compare/merge them.
That means I have a number of tables and each with a number of fields.
I have for a testing field built my logic and a layout so that FM shows me when the local and remote data source are different and shows me two buttons to let me choose which data to merge into the other set.
I could, of course, manually replicate all the formulas and buttons for all fields in all tables, but that would be insane. Is there a way to tell FileMaker "use this layout and script steps on the buttons for all fields, changing the names of the fields as you go" ?
Or, in other words, I have two fields and two buttons. Let's call them DataA::field and DataB::field. I have a layout that shows them side-by-side. That layout has two buttons with attached logic to show the buttons only if the field values are different. Button A has a "single step" formula that says "set field value of B to A" and button B has a formula "set field value of A to B".
Is there a way to replicate those buttons and their logic to all the fields in my table without doing a lot of manual work ?
The answer is YES!
You need...
fmWorkMate
[Makes your FileMaker work]
fmWorkMate is a free Power Toolbox for FileMaker Developers from www.mrwatson.de (that I have written over the last 10 years or so).
I use fmWorkMate myself to do exactly what you are doing! In my case I'm syncing fields between tables of my FileMaker solution and embedded ESS tables, but the process is the same... make one field / bit of code... and then automatically generate ('multiply') the rest.:-)
So, how?
First up download and install fmWorkMate - This is actually the trickiest part of the process, since the latest version is yet to be published (and I will correct this once published)
If you use Mac OS < Catalina you can download the fmWorkMate Bundle from the downloads page
If you use Windows you'll need to download the old Windows version from the downloads page
If you have anything else, or have any troubles, contact me, and I'll get the tool out (at last) or to you (at least)
Here are several examples to illustrate how you can use fmWorkMate to do what you wish:
The above here does not answer the question directly, rather shows how to replace fields A and B with fields C and D.
The examples are nonetheless useful and illustrative as they stand, and the techniques build on each other.
I have added example 4 as the full answer to the question below.
Example 1: From your two Buttons with A and B, create two similar buttons with C and D
In Theory:
Copy your buttons out of FileMaker (CMD+C / ctrl+c)
Convert the FileMaker objects to editable XML with fmCheckMate
Open fmCheckMate
Open fmWorkMate
Choose the fmCheckMate tool (or press CMD+2 / ctrl+2)
Press the button [Convert Clipboard FM ⭤ XML]
Or press CMD+2 / ctrl+2
Or press CMD+OPT+C / ctrl+alt+c)
And if you are not automatically changed to the XML editor view...
Press the edit button (or CMD+3 / ctrl+3) to change to the XML-Edit view
Or set up fmCheckMate to always switch to the XML editor:
fmCheckMate > Settings... > XML editor > Small editor)
Find and Replace text in the XML as needed
Replace field A with field C
Click in the [F]ind field (or press CMD+F / ctrl+F)
Type the name of the field you want to change A
Click in the [R]eplace field (or press TAB or CMD+SHIFT+F / ctrl+shift+F)
Type the name of the field you want to change to C
Replace all occurrences:
Press CMD+OPT+A / ctrl+alt+A
Or (on newer versions of fmCheckMate) Press the [R] button
Or (on older versions of fmCheckMate) Hold ALT and press the [R] button
Replace field B with field D
Repeat with B and D
Convert back to FileMaker objects
Press the [-> FM] Button (or press CMD+OPT+V / ctrl+alt+V)
Paste into FileMaker (CMD+V / ctrl+V)
Voilá!
(Or rather - oops - did we break it?)
In Practice:
For the particular example you have given - using only one-letter field names A and B - the above will break the XML and not work - because the search and replace is across the entire XML, and the letters A and B appear in various places throughout the XML and replacing them will make the XML unreadable.
However, 99.9% of the field names you will actually be replacing will be quite unique and it is turns out to rarely be a problem.
For example, if your fields were named Previous value and Current value and you wanted to change them to Previous event and Current event that would be no problem at all.
Note, however, that just replacing value with event would (probably) break the XML as well, since value is (highly likely) the name of an XML attribute too. In general: Avoid using single word search words like name, id, Layout,.
[And, of course, the table names DataA and DataB would work fine as they are unique/non-conflicting with XML tag and element names.]
Example 2: Multiply a bit of code for multiple fields
Let's say you have a list of 10 fields you want to sync:
CustomerName
Company
Street
HouseNumber
City
ZIP
Country
Item
Quantity
UnitPrice
How can we produce code for these 10 fields in a fraction of the time?
Write the code for your first field
Multiply your code
How?
First prepare fmTextMultiplier:
Start fmTextMultiplier
Open fmWorkMate
Choose the fmTextMultiplier tool
If necessary press [New] (CMD+2 / ctrl+2) to get an empty record
Paste your field list into the empty Replace field
=> Note: The first line appears in the search field
Press the button [Don't duplicate original]
=> The first line is removed from the replace field
=> fmTextMultiplier is ready to go:-)
Then
Create some code for field 1 - e.g. the field named CustomerName
Multiply the code
Copy the code out of FileMaker (CMD+C / ctrl+c)
Paste the XML into fmTextMultiplier
Click in the fmTextMultiplier Text field
Select Edit > Paste FileMaker Clipboard -> XML (or press CMD+ALT+V / ctrl+alt+V)
Click [Multiply Text x Values] (or press CMD+5 / ctrl+5)
Click [-> FM] (or press CMD+6 / ctrl+6)
Paste your code back into FileMaker
Check + tweak your code as necessary
For example, you might want to correct the field data types.
The best thing is, this same method works for field definitions, layout-fields, buttons, script steps, scripts, whatever!
Once you have set up fmTextMultiplier once you can use the same multiplier function to multiply all the different bits of code around the fields.:D
Example 3: Generating a Series of Fields
Say you are building a calendar and need a series of fields to hold the days:
Day 1
Day 2
Day 3
Day 4
Day 5
Day 6
Day 7
Day 8
Day 9
Day 10
Day 11
Day 12
Day 13
Day 14
Day 15
Day 16
Day 17
Day 18
Day 19
Day 20
Day 21
Day 22
Day 23
Day 24
Day 25
Day 26
Day 27
Day 28
Day 29
Day 30
Day 31
Day 32
Day 33
Day 34
Day 35
Day 36
Day 37
Day 38
Day 39
Day 40
Day 41
Day 42
Gee, this is going to be hard work!
Nope!
We shall use fmTextSeries to generate the series automatically and fmTextMultiplier to multiply the Day 1 code.
Generate the list (series) of field names you need using fmTextSeries
Start a fresh fmTextSeries
Open fmWorkMate
Choose fmTextSeries tool
Press New if necessary
Enter the following values into the dialog and press OK
Text: Day 1
Times: 42
Ìncrement: 1
=> The series is already on your clipboard, ready to paste!
Prepare fmTextMultiplier
Go back to fmWorkMate (via the standard 'back' navigation):
Click the mrwatson logo
Or press CMD+1/ ctrl+1
Start a fresh fmTextMultiplier
Choose the fmTextMultiplier tool
Press New to start a new multiplication
Paste the generated field names into the Replace field
Choose [Don't duplicate original]
Multiply your code as in Example 2 above
And repeat for any other such fields - or indeed for any code you need (e.g. Day 1 Event Summary field, Calendar Reset script, Calendar picker layout, ...)
Example 4: Changing direction of Set Field[ DataA::field ; DataB::field ]
So,...
You have a script step (or a button with a script step - or even multiple buttons/steps) that sets 'field A' to 'field B' (or, in your case, a field in table DataA to a field in DataB)...
And you want to change the direction?
Easy! Use a fmCheckMate XSLT transform to swap the source and target fields around!
How?
Additionally to fmWorkMate and fmCheckMate (see above) you'll need the fmCheckMate XSLT library:
This is in the fmWorkMate Bundle from the downloads page
Or can be downloaded from MrWatson's fmCheckMate-XSLT GitHub repo
Once you have copied the fmCheckMate XSLT folder to your documents folder:
Copy the buttons (or script steps)
Convert to XML using fmCheckMate (see above)
Press the [T]ransform button
If this is the first time using fmCheckMate-XSLT the library is loaded
Note: In some (old?) Versions of the library + tool you may see loading errors here - these can be ignored as they are caused by some badly formatted XSLT files, that have no bearing on the further procedure here.
Find and perform the desired transformation
Either in list view
Browse to or find the Swap Set Field Target And Value function
Clicking the function name performs the function
Note:
Clicking other fields filters the list, so you can reduce the list to browse by
Clicking Change to show only Change functions
Clicking Script step to show only the Change Script step functions
Clicking the headers sorts the column
Or in tree view
Click [Change]
Click [Change > Script steps]
Click [Change > Script steps > Swap]
Click [Change > Script steps > Swap > Set]
-...
Click [Change > Script steps > Swap > Set > … > … > Value]
You can change views with the [View] button
Convert the XML back to FM
Paste into FileMaker
Lol! The direction has been magically changed!
Example 5: Multiplying code using TWO separate field lists
You haven't asked for this directly, but this example may save you having to ask another question.
If your FileMaker-fields and SQL-fields have slightly different names, fmTextMultiplier can deal with that too.
Say you have these FileMaker fields (in your DataA table)
CustomerName
Company
Street
HouseNumber
City
ZIP
Country
Item
Quantity
UnitPrice
And these SQL fields:
customer_name
company
street
house_number
city
zip
country
item
quantity
unit_price
And on your layout you have the two fields with labels next to each other:
CustomerName [CustomerName] customer_name [customer_name]
You can multiply these using fmTextMultiplier by using two columns:
First, you need the two columns separated by tabs (or whatever)
CustomerName customer_name
Company company
Street street
HouseNumber house_number
City city
ZIP zip
Country country
Item item
Quantity quantity
UnitPrice unit_price
Set up fmTextMultiplier like this:
Start fmTextMultiplier
Opn fmWorkMate
Choose fmTextMultiplier tool
Press [New] to start a fresh new Multiplication
Paste the above text into the Replace field
Set the Split Values # char/textfield to {{TAB}} (or your chosen delimiter)
Choose [Don't duplicate original]
Then you can multiply your code in four easy steps
Copy your code in FileMaker
Multiply it in fmTextMultiplier - as described above
Paste it into the Text field
Click in the field
Select Edit > Paste FileMaker-Clipboard -> XML
Click [Multiply Text x Values]
Click [-> FM]
Paste the code back into FileMaker
Organise the multiplied objects in your layout
OK, so step 4 is not that easy because all of the multiplied layout objects end up in a big pile on top of one another, which is a real pain to pull apart - if you started with 4 separate layout objects, that is.
On the other hand, if you...
Group the layout objects together before you copy them
You can then just
Paste the pile of objects into FileMaker
Align them horizontally and vertically on top of the original group of objects
Click somewhere to deselect the new objects
Click on the top object
Move it down the layout to the correct position
You can calculate the position = orig_top + height_between_rows * (total_number_of_rows-1)
Select all the objects - including the original one
Choose Arrange > Distribute > Vertically
Et voilá... all the rows are in exactly the correct position!
Example 6 - fmTextConverter
There is an also a tool for performing multiple conversions to a text, fmTextConverter.
So If you have some code that operates on your FileMaker-fields, and you want the same code to do the same to your SQL-fields, you can simply
Set up fmTextConverter
Open fmWorkMate
Open fmTextConverter
Press [New] to create a new text Conversion
Paste the FileMaker-field-names in the Search field
Paste the SQL-field-names in the Replace field
Then
Copy your code out of FileMaker
Convert with fmTextConverter
Paste your code into the Text field as XML
Edit > Paste FileMaker Clipboard -> XML
Press [Convert text now]
Press [-> FM]
Paste it back into FileMaker
Note: If one of your field names is a substring of another field name then the substitution will go wrong, if the substring is converted first.
fmTextConverter highlights this problem and offers a sort button, which sorts longer strings to the top, ensuring that the substring is never converted first!
Note too that fmWorkMate is highly optimised for efficient batch work - there are lots of keyboard shortcuts and settings to make repetitive work efficient.

How can I convert tabs to spaces and vice versa in an existing file

I cannot figure out how to do this for the life of me apart from doing a find-replace on 4 spaces and converting to tabs (Version 0.10.2). I can't think of an editor/IDE that doesn't have a specific feature to do this. Does VSCode?
Since fix of: https://github.com/Microsoft/vscode/issues/1228 the editor supports it out of the box. Simply go for:
F1,
indentationToSpaces or indentationToTabs (depending on your need)
Enter.
Another way to do it is click the current indentation (Tab/Spaces:n) on the footer which will open your indentation options where you can select what you want to do.
If you are trying to convert non-leading tabs to spaces (or vice versa) you can use a regex search and replace.
Press CTRL + H
Click the .* button to search using regular expressions.
To search for tabs enter [\t] in Find box.
Enter spaces in Replace box and perform your replace.
Search box in regex mode:
To round out these answers, I will add my take for converting each tab to n spaces.
Highlight a tab character
Use CTRL + F2 select all occurrences
Press SPACE n times
This is the easiest way to do this (going beyond only converting leading tabs).
Note that this does not convert consecutive tabs to k spaces. It converts each tab. For consecutive tabs please see my comment on jrupe's answer. You will need VS Code find and replace with regular expressions to accomplish that.
Select Replace: CTRL-H
Enter Horizontal Tab in Find box: hold ATL and type 009 on the keypad.
Enter a space(or more spaces) into the Replace box: press space bar
Press Enter to begin replacing Tabs with Space(s).
Press F1 and then type into textbox convert indentation to spaces or whatever you want ones
On Visual Studio, Ctrl+K+F did the trick for me.
Fast forward to 2020/2021, there are some extensions that will give us that conversion. I have just needed that functionality (hence I found this article), and searching for extensions I found:
geocode.spacecadet - providing both TAB->SPC and SPC->TAB, but not updated since 2017, with 1.3k installs, 3.5 review
takumii.tabspace - TAB->SPC, from 2020, 1.5k installs, no reviews
pygc.spacetab - SPC->TAB, from... wait, literally yesterday! (or today depending on your TZ), 2 installs, no reviews

How to do search and replace involving fields in Microsoft Word?

I have a Word document with fields of the reference variety, which occur in the form "[field].[field]"--in other words, there's a period between the two fields. I want to globally replace this with a space.
Word offers the ^d special character to search for fields, but for some reason the query "^d.^d" does not find anything. However, ".^d" does. Now comes the problem, however--what do I specify as the replacement text in order to retain the field code? If using regular expressions, I could use a "Find What Expression" such as \1, but with regexp ("wild card") mode the ^d is not permitted.
I guess I could write a macro...
I would like to add to Bibadia's solution.
An example of an index entry field; we want to change a name we misspelled.
Make sure hidden formatting is displayed (toggle with SHIFT+CTRL+F8).
Make sure wildcards option is not selected. To search for fields, use the opening and closing field braces code (optionally use ^w for spaces, as Bibadia suggested):^19 XE "Deo, John" ^21
Replace won't recognize field braces character, but will allow to insert the clipboard's content. ;). To do that, insert in text the correct entry. CTRL+F9 to insert field and type:XE "Doe, John"
Select the field above and copy
Use ^c in the replace box
Hit Replace All
Ta-da!
It's usually better to go the macro route when finding fields because, as you say, the find algorithm that Word uses doesn't work the way you might hope with fields.
But if you know exactly what the fields contain, you can specify a search pattern that will probably work (however not in wildcard mode).
For example, if you want to look for figure number field pairs such as
{ STYLEREF 1 \s }.{ SEQ Figure \* ARABIC \s 1 }
(which would typically be the same set of fields everywhere in the document)
If you only really need to look for the following:
{ STYLEREF 1 \s }.<any field>
you could ensure that field codes are displayed and search for
^d STYLEREF 1 \s ^21.^d
or
^19 STYLEREF 1 \s ^21.^19
If you need to be more precise, you can spell out the second field as well.
"^d" only works for finding the field beginning, not the field end.
It's a shame that ^w wants to find at least 1 whitespace character because otherwise it would be more robust to look for
^19^wSTYLEREF^w1^w\s^w^21.^19
Perhaps someone else knows how to work around that without using wildcards?
Torzaburo,
I suggest that you do this using a macro. You can start by recording the macro, and later refining your processing steps within the macro.
First turn on the hidden characters by navigating to Home > Paragraph > toggle the show/hide Paragraph symbol. Also, select all and toggle the field codes on (right-click and select "Toggle Field Codes".
Open a new blank Word doc in addition to the one you have open. You will use this later. Start the macro recording and find the field using the "^d" (field code) as you said.
When the field is found, copy only the field text within the brackets, and not the full field reference. While the macro is still recording, ALT + TAB to the new blank document and paste the field code in as plain text.
At this point, do the necessary find & replace processing to the field codes. Highlight the processed field codes, copy, ALT + TAB back to the original document, and paste back between the { } brackets.
Stop the macro recording. Add any further custom processing to the macro VBA.
Select-All and re-toggle the field codes. Update the field codes.
You don't need a macro. Just toggle all field codes on by using Alt+F9. Then do a find and replace for what you want to change. Once the replacement is complete, use Alt+F9 again to toggle the field codes back off.
Disclaimer: I didn't originate this solution, but it's clean and elegant and I thought it should be included here:
(Adapted from Search & Replace Field Codes in Word):
Create or find a single instance of the field you want to convert text to
Toggle Field Codes visible (AltF9)
Copy the code for the field you want to use to the Clipboard (highlight and CtrlC)
Open the Replace dialog box (CtrlH), insert the text you want to replace in the Find What box and then enter ^c in the Replace With box.
This will replace your text with the contents of the Clipboard, turning it into the field code you copied in step 3. It also copies formatting information (font, color, etc.), to control how the field will appear when hidden. (Caveat: I've tested this with Word 2003 under Windows 7 only.)
Coming in late on this, probably way too late for Beth (sorry Beth). And this may not be quite what Beth was looking for. But for anyone interested ...
It sounds like Beth may have created captions throughout the document using INSERT CAPTION (hence the presence of field codes). This means these captions will have been (automatically) created in CAPTION style.
To globally replace the separator "." with " " (space) in such captions, take two steps:
[1] Go to REFERENCES | INSERT CAPTION, then click on NUMBERING and replace the SEPARATOR "." with "EM-DASH". This will replace all separators in captions for the selected label in the CAPTION Window. If you have other labels in use in the document (e.g. FIGURE), select the other labels one by one and repeat this process.
[2] Do a find/replace searching for special character "em-dash" (^+) in style CAPTION, replacing with " ". Click REPLACE ALL.
Voila!
NOTE: This presumes that em-dash does not appear in the caption text anywhere. If it does, then you'll need to do a pre- and post- "fiddle" to ensure these em-dashes are not touched by the global replace above.
The "pre-fiddle" is to do a global find/replace across captions, replacing the em-dash ("^+") with some other string (e.g. "EM-DASH") that doesn't ever occur in any caption's text. Then you do the separator change as described above. Finally, the "post-fiddle" is to restore the em-dashes that were in the captions, by doing a global replace of the string "EM-DASH" with the actual em-dash character "^+".

Can I make a macro in n++ that does a search/replace?

I'm new to n++, but I have been most impressed with this tool so far. I've been trying to record a macro that do a search/replace, but the 'search' part seems to have the initial search text from the recording 'hard-coded' in the macro.
What I want is:
Manually locate the cursor at the beginning of the first line of a fixed format code segment, then Macro actions:
move cursor two lines down
move cursor right x characters
mark charters from pos x to x+n
search and replace all occurrences of the selected text with "{p_'selected text'}"
In an more advanced version, I'd like to add some logic to step 4: only execute the replace part if the # of occurrences are > 1 (e.g. by first adding a count statement, but I'm not sure how to obtain the returned count # from the dialog box)
Is this possible?
While I'm a big fan of Notepad++, this sounds like something I would accomplish with AutoHotKey. You would select the text and copy it to the clipboard. AutoHotKey would read the clipboard, replace the text as you desire, and either replace the clipboard contents, or send it back to your document. Let me know if you would like to go that route.

How to search and replace 2 lines (together) in Eclipse?

I would like to search multiple files via eclipse for the following 2 lines:
#Length(max = L_255)
private String description;
and replace them with these two:
#Length(max = L_255, message="{validator.description.len}")
private String description;
Another tip on how to get the regex for a selected block.
Open one of the files that contains the multiple lines (multiline) to search or replace.
Click Ctrl+F and select "Regular expression". Close the Find/Replace window.
Select the block you need and click again Ctrl+F to open the Find/Replace window.
Now in the Find text box you have the regular expression that exactly matches your selection block.
(I discovered this, only after creating manually a regexp for very long block :)
Search are multi-line by default in Eclipse when you are using regex:
(\#Length\(max = L_255)\)([\r\n\s]+private)
I would like to add "private String description;"
(\#Length\(max = L_255)\)([\r\n\s]+private\s+?String\s+description\s*?;)
replaced by:
\1, message="{validator.description.len}")\2
It works perfectly in a File Search triggered by a CTRL-H.
As mentioned in Tika's answer, you can directly copy the two lines selected in the "Containing Text" field: those lines will be converted as a regexp for you by Eclipse.
CTRL+H does take two lines if you use regexp (and you don't have to write the regexp by yourself, eclipse does that for you).
Select your lines.
Click CTRL+H. The search dialog opens up.
If "Regular expression" is already checked, eclipse will have converted the two lines you search for into regexp for you, click Search.
If "Regular expression" if not already checked", check it and click Cancel (eclipse remembers your choice).
Select your lines again.
Click CTRL+H. The search dialog opens up. This time "Regular expression" is already selected. eclipse will have converted the two lines you search for into regexp for you, click Search.
A quick tip for including multiple lines as part of a manually constructed regular expression:
Where you would normally use .* to match any character zero or more times, instead consider using something like (?:.|\r?\n)*. Or put an extra ? at the end to make it non-greedy.
Explanation: . doesn't match new lines so need to do an "either-or": The parentheses match either the . before the pipe or the new line after it. The ? after \r makes the carriage return before the line feed optional to allow Windows or Unix new lines. The ?: excludes the whole thing as a capturing group (which helps to avoid a stack overflow).
Click Ctrl + F and select "Regular Expression" and then search the lines. In case to perform the same on multiple files, click Ctrl + H, click on 'File Search' and perform the same.
Select the folder that contains all your files and press Ctrl+H.