Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #6342
    Stefan
    Participant

    Sorry, i don’t understand this
    and didn’t found this answer in the help or on the forum.

    In help i found
    WrapMode Property
    [VBScript]
    nMode = object.WrapMode
    object.WrapMode = nMode

    I try
    nMode = Object.WrapMode
    alert nMode

    But get an error ==> [Object needed: object]

    Question:
    how can i do this?
    Something like ==> SET OBJECT = CreateObject(“EEMacro.dll”) ???
    I searched everywhere … :-(

    v8 beta4
    Thanks for an hint, Stefan.

    #6347
    dreftymac
    Participant

    Greetings Stefan,

    This could be documented a little better, because the “object” designation is a little vague. Please take a look at the documentation for

    “Config Object”

    In EmEditor help. This explains a little bit more to help you do what you are trying to do. There is an example in the documentation that shows how to loop through editor.Configs, you can modify that example slightly as shown below:

    cfgs = new Enumerator( editor.Configs );
    for( ; !cfgs.atEnd(); cfgs.moveNext() ){
    cfg = cfgs.item();
    alert( cfg.Name );
    alert( cfg.General.WrapMode ); /// <— this uses the GeneralProp object
    }

    This is in Javascript, but there is a VB example in the documentation as well. The documentation could use some improvements, but since this is a closed-source software I don’t know if users are allowed to make updates, or whether there is a wiki or something like that. If there is hopefully someone will link to it, as that would help a lot.

    Cheers,

    #6348
    Stefan
    Participant

    THX dreftymac,

    EmEditor Home – EmEditor Help – EmEditor Macro Reference > Configs Collection
    Configs collection provides a collection of Config objects.

    This part works
    (I don’t know where this ‘General’ comes from now …?)


    For Each cfg In editor.Configs
    alert cfg.Name
    alert cfg.General.WrapMode
    Next

    I see MsgBoxes like Bat, C’ and C++,…. and ones and zeros, depending to the current state of the settings

    – – –

    But the example in the help

    nMode = OBJECT.WrapMode

    i didn’t bring to work.

    I try a lot of possibilities like
    SET cfg = CreateObject(“editor.Configs”)
    alert cfg.General.WrapMode _ :-( :-D

    – – –

    I want to do this with the command:



    nMode = OBJECT.WrapMode 'store current
    Object.WrapMode = eeWrapByChar 'set other mode
    document.selection.Format eeFormatSplitLines ' execute editor command
    Object.WrapMode = nMode 'restore mode

    Any one can enlighten us :-D

    #6349
    dreftymac
    Participant

    In Java_script:


    var myobject = document.Config.General;
    Window.alert(myobject.WrapMode);

    This is not documented very well, but if you do a little digging, you will see in

    EmEditor Home – EmEditor Help – History – Version 7

    “The Config property was added to the Document Object. “

    further down you will see that Configs is attached to the Editor Object.

    The *General* corresponds to the *GeneralProp* Object. It appears to be a naming convention used by the developer.

    *FoobarProp* Object in the docs => just *Foobar* in your code

    The developer also uses “object” as a general convention in the documentation without always spelling out what the specific object actually is. That’s fine if your goal is to get the documentation done quicker, but not so great if you’re trying to learn from the docs :)

    #6353
    Yutaka Emura
    Keymaster

    Stefan wrote:
    Sorry, i don’t understand this
    and didn’t found this answer in the help or on the forum.

    In help i found
    WrapMode Property
    [VBScript]
    nMode = object.WrapMode
    object.WrapMode = nMode

    I try
    nMode = Object.WrapMode
    alert nMode

    But get an error ==> [Object needed: object]

    Question:
    how can i do this?
    Something like ==> SET OBJECT = CreateObject(“EEMacro.dll”) ???
    I searched everywhere … :-(

    v8 beta4
    Thanks for an hint, Stefan.

    I am sorry the document is not clear. This portion was meant to show the syntax. More examples were needed.
    Here is how you might want to accomplish your task:


    cfg = document.Config;
    cfg.General.WrapMode = eeWrapByWindow;
    cfg.Save();

    #6357
    Stefan
    Participant

    Thanks Yutaka, that works


    cfg = document.Config;
    alert (cfg.General.WrapMode);

    I see an messagebox with an number of the current wrap setting.
    If i switch the wrap mode and execute the macro again i see the corresponding number to that mode.

    – – –

    With


    cfg = document.Config;
    cfg.General.WrapMode = 1; //eeWrapByWindow;
    cfg.Save();

    i am able to switch the mode (and how the text is wrapped) by macro.

    – – –

    Now i try to (understand this and) code this in VBS.

    THX :-D

    #6366
    Stefan
    Participant

    OK, with your all help i was able to code this in VBS.
    Now i can automate the steps to split lines with an macro.

    Unfortunately the save-settings-process take seconds to do.
    So splitting even 10 lines only takes 2 seconds.
    (I also notice the settings-dialog from menu takes up to 5 sec. on different PC to appear)
    (tested with EmEditor Professional 8.00 beta 4)

    Here is my working but basic macro to split lines with pure editor commands:

    Attention:
    There is no error handling right now.
    Use on Test files only!

    Split-Wrap-Reformat.vbee


    #title = Reformat
    #tooltip = Split selected lines to reformat paragraph
    '// very basic VBS-macro, works on selected lines only

    ' reference to object (is this an right description???)
    SET myOBJECT = DOCUMENT.Config

    'get current wrap mode and store it into a var
    StartWrapMode = myOBJECT.General.WrapMode

    'Hint: General.WrapMode are 0=eeWrapNone, 1=eeWrapByChar, 2=eeWrapByWindow, 3=eeWrapByPage
    'Hint: For eeWrapByChar first set "Configuration Properties - General tab >Normal Line Margin"

    'set desired wrap mode
    myOBJECT.General.WrapMode = 1
    myOBJECT.Save

    'execute
    document.selection.Format eeFormatSplitLines

    'set back start wrap mode
    myOBJECT.General.WrapMode = StartWrapMode
    myOBJECT.Save
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.