NW 6.5 hebrew files and Styles bugs(?).

Have a problem? A question? This is the place for answers from other Express users.
Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

NW 6.5 hebrew files and Styles bugs(?).

Post by Ruchama »

Hi there,
I am new to this forum but use NW since its start. I just got myself the intel machine, (OS 10.4.7) and NWE 2.7.

Before asking, let me just say the spirit in this forum is so positive and welcoming that I am encouraged to ask my questions, and I thank the members and nisus people for the info I have already gained, and for that to come.

First, I join many members in missing (DEARLY) attributed find&replace and I wait eagerly for it to re-appear.
Also, I miss the size 10 standard under the SIZE menu.
and Macros...Please...

I am transferring loads of Hebrew files from NW 6.5. All numbers in NWE are flipped right to left, that is 12 becomes 21, 345 becomes 543 etc. this does not depend on encoding. I did find the term with PowerFind Pro how to switch them all back with one command, but thought this needs to be reported.

Problems: I have edited the New file under preferences to to include several menu-keys, language, styles etc.

1. For some reason, a menu-key assigned to Size12 does NOT appear on the menu, but IS working so this seems to be some display bug.

2. All the Menu-Keys and Styles etc work ok when openning a new file, including a Size10 character Style (with a shortkey).
However- when openning a NW 6.5 file (as a new file) the new Character-Style does not appear and is not usable while other (modified) Styles and Keys work ok.

Is that bug? Can anyone help?

Thanks, Ruchama

cchapin
Posts: 419
Joined: 2004-02-25 18:28:40
Location: Maryland, USA

Re: NW 6.5 hebrew files and Styles bugs(?).

Post by cchapin »

Ruchama wrote:All the Menu-Keys and Styles etc work ok when openning a new file, including a Size10 character Style (with a shortkey).
However- when openning a NW 6.5 file (as a new file) the new Character-Style does not appear and is not usable while other (modified) Styles and Keys work ok.

Is that bug? Can anyone help?
Welcome to the forum, Ruchama!

Let me see if I understand the problem you're having. You've created a Nisus New File (a default template) that is to your liking. However, when you open a legacy file (created in Nisus Writer "Classic"), it does not have a particular character style that you created in the Nisus New File. Is that correct? (If I'm wrong, the next paragraph will be pretty meaningless.)

I was not a Nisus Writer "Classic" user, so there might be something I'm missing, but it might be a misunderstanding of how the Nisus New File works. Changes made to the Nisus New File template won't carry over to pre-existing files automatically. You can copy a style from one document to another, but I don't know way to do this automatically or in a batch procedure.

If this answer is on the right track, let's see what kind of solution we can come up with for you.

--Craig

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

reply

Post by Ruchama »

Hi craig,

thanks for your quick reply.
I do understand the logic of not implying retroactively Styles on existing files. However, if file is opened as a 'new file', using the tamplate, why shouldn't I have the option to continue editing it with special styles? I don't speak about Normal or Headings etc, but a special character Style which is used here and there, that has nothing to do with the structure or the origin of the file?
Anyway, specifically, I need a shortcut to size10 which will be avaiable for all files. Otherwise I will need to copy the style to loads of files. if there was a way todo it NOT thorugh Styles (like being in the regular Size menu..) it would suit me as well.
thanks

cchapin
Posts: 419
Joined: 2004-02-25 18:28:40
Location: Maryland, USA

Re: reply

Post by cchapin »

Ruchama wrote:However, if file is opened as a 'new file', using the tamplate, why shouldn't I have the option to continue editing it with special styles?
The "Open as New File" checkbox in the Open dialog applies only to templates, I'm afraid. If it is checked, it opens a new document based on that template. If it is unchecked, it opens the template for editing.
Ruchama wrote:Anyway, specifically, I need a shortcut to size10 which will be avaiable for all files. Otherwise I will need to copy the style to loads of files. if there was a way todo it NOT thorugh Styles (like being in the regular Size menu..) it would suit me as well.
thanks
I think I can help you there.

1. Click the Macros menu, then New Perl Script.
2. Type the following.

Format:Size:9
Format:Size:Increase

3. Click the Macro menu, then Save As Macro.
4. Give the macro a name (e.g., "10 Points").
5. Navigate to ~/Library/Application Support/Nisus Writer/Macros.
6. Click the Save button.

That creates a macro that sets text size to 10 points. The macro will appear in your Macro menu. All that remains is to assign it a Menu Key, which you know how to do.

--Craig

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

Simple and working.. Great!

Thanks Craig, a lot!

I dare to take advantage of your good will: Using your idea, I tried to write a simple macro without knowing much about Perl, with the following:

#destination front selection
Format:Size:9
print "text";
Format:Size:12

for printing "text" in size9.
When trying to run it, I keep getting the message:
syntax error at /tmp/NisusScript line 2, near "Format:Size:"

Any idea what's the error? Sorry for the ignorance....

Ruchama

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

Sorry Craig,
just from looking around other macro's I realized that the whole concept of what I wrote is wrong so ignore it.
but- searching the forum with several terms, I couldn't see anyone assigning attributes to a printed text- that is (ignoring syntax and formats)

operation 1: set attribute(s)
operation 2: print to file some (attributed) text

Is that at all possible?

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

Ruchama, currently it's rather tricky to do, as it involves knowledge of RTF codes, but possible. Here's something that should do about what you want:

Code: Select all

#Nisus Macro Block
#Send Text as RTF
#source front selection
#destination front selection
#after execution
#Format:Size:12
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

$message = 'hello world';
$fontSize = 9; # in points

$rtfSize = $fontSize * 2;
print "{\\rtf1\\mac{\\fs$rtfSize $message}}";
We know our macros could use some work to make this kind of thing easier in the future.

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

Hi Martin, thanks

I tried the macro and got the error message:
"Bad Menu in macro
The macro contains an unknown menu path:
Format:Size:12 "

Sound strange, as it appears on the menu.. I work with Hebrew language as default, but changing it to english did not help. continuing the macro resulted in printing 'hello world' but not in changing back to size 12.
Does it have anything to do with the bug I reported about 'size 12 MenuKey does not stick?

Is there a way to get such a macro to work with a hebrew text? This would ease my life quite a bit since I used to work with lots of such macros in NW 6.5..

and- where can I look into the correct parameters for such attributes (such as font, style ect)?

User avatar
Patrick J
Posts: 124
Joined: 2006-06-16 16:17:50
Location: Brighton & Hove, UK
Contact:

Post by Patrick J »

Ruchama wrote:Hi Martin, thanks

I tried the macro and got the error message:
"Bad Menu in macro
The macro contains an unknown menu path:
Format:Size:12 "
Hi

I think there is a space after the 12 which shouldn't be there. You probably copied the macro from the web-page and the web-page has put in extra spaces at the end of the line.

You can see in the dialogue you've quoted that there is a space after the 12 but I don't think there should be.

I can't comment on any other aspect of your query because I hardly know Perl (the language used for the macro) and I don't know what it's for.

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

Thanks Patrick, indeed- that was the problem! it runs smoothly now.

If anyone out there knows about printing a Hebrew (or any other language as a reference) in a Macro, I would be happy to hear about it.

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

Ruchama wrote:If anyone out there knows about printing a Hebrew (or any other language as a reference) in a Macro, I would be happy to hear about it.
I'm not sure I understand exactly what you want. Do you just want to print some Hebrew characters/text?

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

Sorry for not being clear,

Whatwould be extreamly useful for me is exactly the same macro you have suggested- only the text should be in Hebrew.- If I just replace "Hello World" with a hebrew text like "????", I get "?©?ú?ï?ù" being typed.
In addition- when running the (original) macro on a file with Hebrew Language as default (cursor being at the right of the document), the Language of the paragraph is switched to English (cursor is at the left). Adding "#Format:Language:Hebrew" after execution does not help.

also, for other applications (but not as useful for me as the above) If I knew where to look for examples with other parameters like font, style etc I could be more independant but searching the web under RTF code, hebrew perl or some other did not give me much of intelligent info..

Thanks for your patience and good will... Ruchama

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

Ruchama wrote:Whatwould be extreamly useful for me is exactly the same macro you have suggested- only the text should be in Hebrew.
OK, let's see if we can make the macro you would like. Here's something that should do the trick:

Code: Select all

#Nisus Macro Block
#Send Text as RTF 
#source front selection 
#destination front selection 
#after execution 
#Format:Size:12
#End Nisus Macro Block 
use utf8; 
binmode(STDIN, ":utf8"); 
binmode(STDOUT, ":utf8"); 

$message = '\u1488 ?\u1489 ?\u1510 ?\u1491 ?\u1506 ?\u1508 ?'; 
$fontSize = 9; # in points 

$rtfSize = $fontSize * 2; 
print "{\\rtf1\\mac{\\lang1037\\fs$rtfSize $message}}";
Here are the key changes:

1. The control "\lang1037" is RTF for the Hebrew language.
2. The message now contains Unicode code points to specify the Hebrew letters. The easiest way to customize the message would probably be for you to save the Hebrew text from Express as an RTF file and then look at the Unicode code points it uses.
Adding "#Format:Language:Hebrew" after execution does not help.
This was a good idea on your part, but unfortunately the text inserted by a macro is not selected, so setting the language does not affect it.
If I knew where to look for examples with other parameters like font, style etc I could be more independant but searching the web under RTF code, hebrew perl or some other did not give me much of intelligent info..
As much as we love users willing to learn and become independent, it is unlikely that learning RTF is something a user should (or would) want to do. My advice for now is to just bug us on the forum to help you out :) But know that we have some macro enhancements planned that will make the kind of task you are trying to accomplish here easier.

Ruchama
Posts: 213
Joined: 2006-08-19 18:35:27

Post by Ruchama »

It works just fine, with a meaningfull text too :D .
I have noticed that the change of direction to left-to right happens only when the macro is applied at the beginning of the paragraph..
I made the following change AfterExecution

and it looks ok- is that a correct general solution or should I expect trouble at a certain positioning?

#Nisus Macro Block
#Send Text as RTF
#source front selection
#destination front selection
#after execution
#Format:Size:12
#Format:Paragraph Writing Direction:Right To Left
#Format:Paragraph Alignment:Align Right
#End Nisus Macro Block
use utf8;
binmode(STDIN, ":utf8");
binmode(STDOUT, ":utf8");

$message = '\u1495 ?\u1505 ?\u1523 ?';
$fontSize = 9; # in points

$rtfSize = $fontSize * 2;
print "{\\rtf1\\mac{\\lang1037\\fs$rtfSize $message}}";


I don't like either the idea of learning RTF but I also don't like to bug people.... but you offered so:
another two parameters I used in my macros were: Bold and Font- if you give me an example of how to apply a certain font and/or Bold I would be really greatfull (not that I am not greatfull now..)

Truely- Martin, I appreciate very much your help- it enables such major upgrade in my work: THANKS!

Ruchama

User avatar
martin
Official Nisus Person
Posts: 4925
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Post by martin »

Ruchama wrote:It works just fine, with a meaningfull text too :D .
hehe, yeah
and it looks ok- is that a correct general solution or should I expect trouble at a certain positioning?
That looks fine to me. The only unexpected behavior might be if you run your macro on some non-Hebrew text. The whole paragraph will be made right-to-left. But probably this is not an issue for you.
another two parameters I used in my macros were: Bold and Font- if you give me an example of how to apply a certain font and/or Bold I would be really greatfull (not that I am not greatfull now..)
Bold is relatively easy, just insert a "b" control. Here are some other common controls for character formatting:

Code: Select all

\b means bold
\i means italic
\sub means subscript
\super means superscript
\ul means underline
Fonts are more tricky. You'll have to include a "font table" near the start of the RTF. Here's an example font table:

Code: Select all

{\fonttbl {\f0 \fnil \fcharset77 Times New Roman{\*\falt Times};}{\f1 \fnil \fcharset77 TimesNewRomanPSMT{\*\falt Times New Roman};}{\f2 \fnil \fcharset77 LucidaGrande{\*\falt Lucida Grande};}{\f3 \fnil \fcharset82 NewPeninimMT-Inclined{\*\falt New Peninim MT};}}
Basically it lists all the fonts that may be used in the RTF document. This is something that is probably best copied from a saved RTF file, as the font names may not be what you expect. Also, it may be important to get the character sets right (though most Mac fonts use "fcharset77").

Once you've got your font table you can apply a font using its number. For instance, from the above table we can see that New Peninim has been marked as font number 3. To apply it we simply add the control "\f3" in our document.

Here is your macro again, this time inserting text using bold New Peninim font:

Code: Select all

#Nisus Macro Block 
#Send Text as RTF 
#source front selection 
#destination front selection 
#after execution 
#Format:Size:12
#Format:Paragraph Writing Direction:Right To Left
#Format:Paragraph Alignment:Align Right
#End Nisus Macro Block 
use utf8; 
binmode(STDIN, ":utf8"); 
binmode(STDOUT, ":utf8"); 

$message = '\u1495 ?\u1505 ?\u1523 ?'; 
$fontSize = 9; # in points 
$fontTable = '{\fonttbl {\f0 \fnil \fcharset77 Times New Roman{\*\falt Times};}{\f1 \fnil \fcharset77 TimesNewRomanPSMT{\*\falt Times New Roman};}{\f2 \fnil \fcharset77 LucidaGrande{\*\falt Lucida Grande};}{\f3 \fnil \fcharset82 NewPeninimMT-Inclined{\*\falt New Peninim MT};}}';

$rtfSize = $fontSize * 2; 
print "{\\rtf1\\mac$fontTable {\\lang1037\\b\\f3\\fs$rtfSize $message}}"; 
Truely- Martin, I appreciate very much your help- it enables such major upgrade in my work: THANKS!
Sure, I'm happy to help!

Post Reply