The state of the Macro system

Ask questions about how to create a script or swap scripts with other users.
Post Reply
User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

The state of the Macro system

Post by rjbill »

It looks like the state of the Macro system is questionable, full of bugs,
and things that do not work, and more or less unusable.

Is that true?
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

Re: The state of the Macro system

Post by rjbill »

I guess the system more or less kind of works.

But it is WAY too finicky.
And the error reporting is abominable.

I'm trying to modify a JS script that someone showed me in another post and it's HELL to work on.

Right now all it's saying is "Not enough actual parameters".

No line number of the error.

And I don't know if it's a "compilation" error or a run-time error.

Plus it's not anywhere close to "standard Javascript" that I can see or tell.

It's basically unusable.

I guess I could try VBScript. Maybe it's better?

Here is the code if there is any way anyone can tell what might be wrong.

Code: Select all

// Replace extended characters with HTML Entity codes
// &amp is not processed

function replaceWithEntities()
{
   var asEntities[200];
   var asChars[200];

   asChars[0]  = "\"";    asEntities[0]   = """;
   asChars[1]  = "'";     asEntities[1]   = "'";
   asChars[2]  = "¡";     asEntities[2]   = "¡";
   asChars[3]  = "¢";     asEntities[3]   = "¢";
   asChars[4]  = "£";     asEntities[4]   = "£";
   asChars[5]  = "¤";     asEntities[5]   = "¤";
   asChars[6]  = "¥";     asEntities[6]   = "¥";
   asChars[7]  = "¦";     asEntities[7]   = "¦";
   asChars[8]  = "§";     asEntities[8]   = "§";
   asChars[9]  = "¨";     asEntities[9]   = "¨";
   asChars[10]  = "©";    asEntities[10]  = "©";
   asChars[11]  = "ª";    asEntities[11]  = "ª";
   asChars[12]  = "«";    asEntities[12]  = "«";
   asChars[13]  = "¬";    asEntities[13]  = "¬";
   asChars[14]  = "®";    asEntities[14]  = "®";
   asChars[15]  = "¯";    asEntities[15]  = "¯";
   asChars[16]  = "°";    asEntities[16]  = "°";
   asChars[17]  = "±";    asEntities[17]  = "±";
   asChars[18]  = "²";    asEntities[18]  = "²";
   asChars[19]  = "³";    asEntities[19]  = "³";
   asChars[20]  = "´";    asEntities[20]  = "´";
   asChars[21]  = "µ";    asEntities[21]  = "µ";
   asChars[22]  = "¶";    asEntities[22]  = "¶";
   asChars[23]  = "·";    asEntities[23]  = "·";
   asChars[24]  = "¸";    asEntities[24]  = "¸";
   asChars[25]  = "¹";    asEntities[25]  = "¹";
   asChars[26]  = "º";    asEntities[26]  = "º";
   asChars[27]  = "»";    asEntities[27]  = "»";
   asChars[28]  = "¼";    asEntities[28]  = "¼";
   asChars[29]  = "½";    asEntities[29]  = "½";
   asChars[30]  = "¾";    asEntities[30]  = "¾";
   asChars[31]  = "¿";    asEntities[31]  = "¿";
   asChars[32]  = "À";    asEntities[32]  = "À";
   asChars[33]  = "Á";    asEntities[33]  = "Á";
   asChars[34]  = "Â";    asEntities[34]  = "Â";
   asChars[35]  = "Ã";    asEntities[35]  = "Ã";
   asChars[36]  = "Ä";    asEntities[36]  = "Ä";
   asChars[37]  = "Å";    asEntities[37]  = "Å";
   asChars[38]  = "Æ";    asEntities[38]  = "Æ";
   asChars[39]  = "Ç";    asEntities[39]  = "Ç";
   asChars[40]  = "È";    asEntities[40]  = "È";
   asChars[41]  = "É";    asEntities[41]  = "É";
   asChars[42]  = "Ê";    asEntities[42]  = "Ê";
   asChars[43]  = "Ë";    asEntities[43]  = "Ë";
   asChars[44]  = "Ì";    asEntities[44]  = "Ì";
   asChars[45]  = "Í";    asEntities[45]  = "Í";
   asChars[46]  = "Î";    asEntities[46]  = "Î";
   asChars[47]  = "Ï";    asEntities[47]  = "Ï";
   asChars[48]  = "Ð";    asEntities[48]  = "Ð";
   asChars[49]  = "Ñ";    asEntities[49]  = "Ñ";
   asChars[50]  = "Ò";    asEntities[50]  = "Ò";
   asChars[51]  = "Ó";    asEntities[51]  = "Ó";
   asChars[52]  = "Ô";    asEntities[52]  = "Ô";
   asChars[53]  = "Õ";    asEntities[53]  = "Õ";
   asChars[54]  = "Ö";    asEntities[54]  = "Ö";
   asChars[55]  = "×";    asEntities[55]  = "×";
   asChars[56]  = "Ø";    asEntities[56]  = "Ø";
   asChars[57]  = "Ù";    asEntities[57]  = "Ù";
   asChars[58]  = "Ú";    asEntities[58]  = "Ú";
   asChars[59]  = "Û";    asEntities[59]  = "Û";
   asChars[60]  = "Ü";    asEntities[60]  = "Ü";
   asChars[61]  = "Ý";    asEntities[61]  = "Ý";
   asChars[62]  = "Þ";    asEntities[62]  = "Þ";
   asChars[63]  = "ß";    asEntities[63]  = "ß";
   asChars[64]  = "à";    asEntities[64]  = "à";
   asChars[65]  = "á";    asEntities[65]  = "á";
   asChars[66]  = "â";    asEntities[66]  = "â";
   asChars[67]  = "ã";    asEntities[67]  = "ã";
   asChars[68]  = "ä";    asEntities[68]  = "ä";
   asChars[69]  = "å";    asEntities[69]  = "å";
   asChars[70]  = "æ";    asEntities[70]  = "æ";
   asChars[71]  = "ç";    asEntities[71]  = "ç";
   asChars[72]  = "è";    asEntities[72]  = "è";
   asChars[73]  = "é";    asEntities[73]  = "é";
   asChars[74]  = "ê";    asEntities[74]  = "ê";
   asChars[75]  = "ë";    asEntities[75]  = "ë";
   asChars[76]  = "ì";    asEntities[76]  = "ì";
   asChars[77]  = "í";    asEntities[77]  = "í";
   asChars[78]  = "î";    asEntities[78]  = "î";
   asChars[79]  = "ï";    asEntities[79]  = "ï";
   asChars[80]  = "ð";    asEntities[80]  = "ð";
   asChars[81]  = "ñ";    asEntities[81]  = "ñ";
   asChars[82]  = "ò";    asEntities[82]  = "ò";
   asChars[83]  = "ó";    asEntities[83]  = "ó";
   asChars[84]  = "ô";    asEntities[84]  = "ô";
   asChars[85]  = "õ";    asEntities[85]  = "õ";
   asChars[86]  = "ö";    asEntities[86]  = "ö";
   asChars[87]  = "÷";    asEntities[87]  = "÷";
   asChars[88]  = "ø";    asEntities[88]  = "ø";
   asChars[89]  = "ù";    asEntities[89]  = "ù";
   asChars[90]  = "ú";    asEntities[90]  = "ú";
   asChars[91]  = "û";    asEntities[91]  = "û";
   asChars[92]  = "ü";    asEntities[92]  = "ü";
   asChars[93]  = "ý";    asEntities[93]  = "ý";
   asChars[94]  = "þ";    asEntities[94]  = "þ";
   asChars[95]  = "ÿ";    asEntities[95]  = "ÿ";
   asChars[96]  = "Œ";    asEntities[96]  = "Œ";
   asChars[97]  = "œ";    asEntities[97]  = "œ";
   asChars[98]  = "Š";    asEntities[98]  = "Š";
   asChars[99]  = "š";    asEntities[99]  = "š";
   asChars[100] = "Ÿ";    asEntities[100] = "Ÿ";
   asChars[101] = "ƒ";    asEntities[101] = "ƒ";
   asChars[102] = "ˆ";    asEntities[102] = "ˆ";
   asChars[103] = "˜";    asEntities[103] = "˜";
   asChars[104] = "?";    asEntities[104] = "Α";
   asChars[105] = "?";    asEntities[105] = "Β";
   asChars[106] = "G";    asEntities[106] = "Γ";
   asChars[107] = "?";    asEntities[107] = "Δ";
   asChars[108] = "?";    asEntities[108] = "Ε";
   asChars[109] = "?";    asEntities[109] = "Ζ";
   asChars[110] = "?";    asEntities[110] = "Η";
   asChars[111] = "T";    asEntities[111] = "Θ";
   asChars[112] = "?";    asEntities[112] = "Ι"
   asChars[113] = "?";    asEntities[113] = "Κ";
   asChars[114] = "?";    asEntities[114] = "Λ";
   asChars[115] = "?";    asEntities[115] = "Μ";
   asChars[116] = "?";    asEntities[116] = "Ν";
   asChars[117] = "?";    asEntities[117] = "Ξ";
   asChars[118] = "?";    asEntities[118] = "Ο";
   asChars[119] = "?";    asEntities[119] = "Π";
   asChars[120] = "?";    asEntities[120] = "Ρ";
   asChars[121] = "S";    asEntities[121] = "Σ";
   asChars[122] = "?";    asEntities[122] = "Τ";
   asChars[123] = "?";    asEntities[123] = "Υ";
   asChars[124] = "F";    asEntities[124] = "Φ";
   asChars[125] = "?";    asEntities[125] = "Χ";
   asChars[126] = "?";    asEntities[126] = "Ψ";
   asChars[127] = "O";    asEntities[127] = "Ω";
   asChars[128] = "a";    asEntities[128] = "α";
   asChars[129] = "ß";    asEntities[129] = "β";
   asChars[130] = "?";    asEntities[130] = "γ";
   asChars[131] = "d";    asEntities[131] = "δ";
   asChars[132] = "e";    asEntities[132] = "ε";
   asChars[133] = "?";    asEntities[133] = "ζ";
   asChars[134] = "?";    asEntities[134] = "η";
   asChars[135] = "?";    asEntities[135] = "θ";
   asChars[136] = "?";    asEntities[136] = "ι";
   asChars[137] = "?";    asEntities[137] = "κ";
   asChars[138] = "?";    asEntities[138] = "λ";
   asChars[139] = "µ";    asEntities[139] = "μ";
   asChars[140] = "?";    asEntities[140] = "ν";
   asChars[141] = "?";    asEntities[141] = "ξ";
   asChars[142] = "?";    asEntities[142] = "ο";
   asChars[143] = "p";    asEntities[143] = "π";
   asChars[144] = "?";    asEntities[144] = "ρ";
   asChars[145] = "?";    asEntities[145] = "ς";
   asChars[146] = "s";    asEntities[146] = "σ";
   asChars[147] = "t";    asEntities[147] = "τ";
   asChars[148] = "?";    asEntities[148] = "υ";
   asChars[149] = "f";    asEntities[149] = "φ";
   asChars[150] = "?";    asEntities[150] = "χ";
   asChars[151] = "?";    asEntities[151] = "ψ";
   asChars[152] = "?";    asEntities[152] = "ω";
   asChars[153] = "?";    asEntities[153] = "ϑ";
   asChars[154] = "?";    asEntities[154] = "ϒ";
   asChars[155] = "?";    asEntities[155] = "ϖ";
   asChars[156] = "–";    asEntities[156] = "–";
   asChars[157] = "—";    asEntities[157] = "—";
   asChars[158] = "‘";    asEntities[158] = "‘";
   asChars[159] = "’";    asEntities[159] = "’";
   asChars[160] = "‚";    asEntities[160] = "‚";
   asChars[161] = "“";    asEntities[161] = "“";
   asChars[162] = "”";    asEntities[162] = "”";
   asChars[163] = "„";    asEntities[163] = "„";
   asChars[164] = "†";    asEntities[164] = "†";
   asChars[165] = "‡";    asEntities[165] = "‡";
   asChars[166] = "•";    asEntities[166] = "•";
   asChars[167] = "…";    asEntities[167] = "…";
   asChars[168] = "‰";    asEntities[168] = "‰";
   asChars[169] = "'";    asEntities[169] = "′";
   asChars[170] = "?";    asEntities[170] = "″";
   asChars[171] = "‹";    asEntities[171] = "‹";
   asChars[172] = "›";    asEntities[172] = "›";
   asChars[173] = "?";    asEntities[173] = "‾";
   asChars[174] = "/";    asEntities[174] = "⁄";
   asChars[175] = "€";    asEntities[175] = "€";
   asChars[176] = "™";    asEntities[176] = "™";
   asChars[177] = "?";     asEntities[177] = "←";
   asChars[178] = "?";     asEntities[178] = "↑";
   asChars[179] = "?";     asEntities[179] = "→";
   asChars[180] = "?";     asEntities[180] = "↓";
   asChars[181] = "?";     asEntities[181] = "↔";
   asChars[182] = "?";     asEntities[182] = "∂";
   asChars[183] = "?";     asEntities[183] = "∏";
   asChars[184] = "?";     asEntities[184] = "∑";
   asChars[185] = "-";     asEntities[185] = "−";
   asChars[186] = "v";     asEntities[186] = "√";
   asChars[187] = "8";     asEntities[187] = "∞";
   asChars[188] = "n";     asEntities[188] = "∩";
   asChars[189] = "?";     asEntities[189] = "∫";
   asChars[190] = "˜";     asEntities[190] = "≈";
   asChars[191] = "?";     asEntities[191] = "≠";
   asChars[192] = "=";     asEntities[192] = "≡";
   asChars[193] = "=";     asEntities[193] = "≤";
   asChars[194] = "=";     asEntities[194] = "≥";
   asChars[195] = "?";     asEntities[195] = "◊";
   asChars[196] = "?";     asEntities[196] = "♠";
   asChars[197] = "?";     asEntities[197] = "♣";
   asChars[198] = "?";     asEntities[198] = "♥";
   asChars[199] = "?";     asEntities[199] = "♦";

   Document.BeginUpdate();

   goReplace.Enabled = false;
   goCancel.Enabled = false;

   var sText = Document.SelText;

   if (sText == "") {
      Document.SelectAll;
      sText = Document.SelText;
   }

   for (var ii = 0;  ii < asChars.length;  ii++) {

      sText = ScriptUtils.WstringReplaceAll (sText, asChars[ii], asEntities[ii]);

   }

   Document.SelText = sText;
   Document.EndUpdate();

   ShowMessage ("Done!");

   goForm.ModalResult = mrOk;

   return;
} // replaceWithEntities


function exit()
{
   goForm.ModalResult = mrOk;

   return;
} // exit

   // build up main app window

   goForm = new TForm (nil);
   goForm.Caption = "Replace Entities";
   goForm.BorderStyle = bsDialog;
   goForm.Position = poScreenCenter;
   goForm.Width = 250;
   goForm.Height = 80;

   goReplace = new TButton (goForm);
   goReplace.Parent = goForm;
   goReplace.Name = "btnReplace";
   goReplace.SetBounds (20, 15, 95, 25);
   goReplace.Caption = "Replace";
   goReplace.OnClick = &replaceWithEntities;

   goCancel = new TButton (goForm);
   goCancel.Parent = goForm;
   goCancel.Name = "btnCancel";
   goCancel.SetBounds (130, 15, 95, 25);
   goCancel.Caption = "Cancel";
   goCancel.OnClick = &exit;

   // show the main dialog

   goForm.ShowModal;
   goForm.Free;
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

Re: The state of the Macro system

Post by rjbill »

I semi-randomly discovered the problem.

It's this line:

Code: Select all

   for (var ii = 0;  ii < asChars.length;  ii++) {
Apparently it is impossible, or not allowed, to use the .length property of a string array variable.

Afaik, that is standard JS.

I also tried to remove the hard-coded [200] dimensioning of the array and it wouldn't allow that, either.

That's messed up.

Is this "JS script product" from some place where you can go and find more information at their website?
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

User avatar
rjbill
Posts: 832
Joined: 13 Jun 2011 06:36

Re: The state of the Macro system

Post by rjbill »

The script version that replaces the characters with HTML entities
changes all of the alpha characters, too.

So something weird is going on with the replace command.

It might have something to do with the character encoding of the document?

Any ideas?

Anyone?
RJTE version 14.64 (actual) - 64-bit
Win 10 Pro 64-bit 8 GB RAM Intel Core i7-6700 3.40 GHz SCSI Hard Drive 1 TB

Note: The signature is dynamic, not static,
so it may not show the correct version above
that was in use at the time of the post.

User avatar
Rickard Johansson
Site Admin
Posts: 6001
Joined: 19 Jul 2006 14:29

Re: The state of the Macro system

Post by Rickard Johansson »

The script engine doesn't work well with Unicode. I'm trying to rewrite the code (not originally written by me) 8)

User avatar
pjj
Posts: 1784
Joined: 13 Oct 2009 13:48
Location: Kraków, Poland

Re: The state of the Macro system

Post by pjj »

Rickard,

does this mean you're going to stick to FastScript? No chance for other/better documented/more flexible script engine? FS is a no-go IMO, not in the long run.
Alium tibi quaere fratrem; hic, quem tuum putas, meus est. Titus Flāvius Caesar Vespasiānus Augustus

Post Reply