How to edit a cut and copied document with proper formating.

44 views
Skip to first unread message

Anson Glinsky

unread,
Sep 30, 2021, 11:57:10 PM9/30/21
to mementodatabase
Good evening all....

Just a quick question.... I cut and paste a lot of snipets of auto information from scale model instruction manuals.  I use an OCR scanner to capture the image.

Some times the text copies perfectly, other times there is a hard indent between each line in the OCR scan.

Is there an app that can be used to format text so it would fit into the field that was created ( Text ) ? Or is there a setting that I can change in the app to format text properly with the field I am cutting and pasting to?

The formatting is a bother.  The information is in the field, but it is hard to read properly.

Any help would be appreciated.

Regards,

Anson

Bill Crews

unread,
Oct 1, 2021, 9:12:40 AM10/1/21
to Anson Glinsky, mementodatabase
I'm sorry to answer with a solution involving JavaScript (JS); I know that's an impediment for a lot of people, and I hope someone responds with something that doesn't involve JS.

But anyway, JS has a method of the String object that I think will do just what you need. It's called trim, and it's trivial to use. It just returns a new string with the white space taken off of the front & back. With the exception that it is JS, it is truly trivial.

First, the value of a Text field in Memento is a String object, so that's a natural thing. Second, a method is merely a function that works on an object, like a String object, so that's kind of natural, too.

Here's how ya use it...

Since the value of a String field, like a Text field or a Barcode field, is a String object, you can just say field().trim() in your script code. See the attached screenshot for the Mozilla Developer Network (MDN) documentation of trim(). Mozilla is the organization that owns & oversees JS.

So, usually the simplest way to do JS in Memento is to use a JavaScript field. So, if you add a JavaScript field in Edit Library and give it the script...
field("Your field name here").trim();  //  Doing that will cause the value of the JS field to be the value of the untrimmed field trimmed.

If you prefer a trigger or action script, you'll need to identify which entry is the current one, but otherwise, it's the same. In a trigger or action script, the current entry is provided by the entry() function, so in this case, you'll not add a JS field, but instead, you'll either change the value of the untrimmed field to its trimmed value, or you'll add a clone field (identical to the untrimmed field) to hold the trimmed value. This clone field, since it is a clone, can then act just like the original field in all ways; it's a duplicate. In this case, the trimming is done once to the clone field and does not affect the original field in any way. The code will be ...
entry().set ("Your field name here", entry().field("Your field name here").trim();  // Changes the field in place. Considerably more noisy, but still trivial.
or, for a clone...
entry().set ("Your clone field's name here", entry().field("Your field name here").trim();  // Makes a trimmed copy of your original field. Considerably more noisy, but still trivial.

Good luck. Let me know if I can be of further assistance.


--
You received this message because you are subscribed to the Google Groups "mementodatabase" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mementodataba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mementodatabase/8ba3deaf-311c-4f9e-825c-e05bfa5e6fadn%40googlegroups.com.
Screenshot_20211001-081931_Google.jpg

Er Mo

unread,
Oct 1, 2021, 2:09:50 PM10/1/21
to mementodatabase
Hallo
Es gibt für Android eine Tastatur APP die das Scannen übernimt und das Ergebnis einträgt . Da könnte man vor den Speichern noch korekturen durchfüren .Der Name ist " Scanner Keyboard "

Hello
There is a keyboard APP for Android that takes over the scanning and enters the result. You could do some corrections before saving. The name is "Scanner Keyboard"
Reply all
Reply to author
Forward
0 new messages