Scripts discussion (2)

Discuss and announce AkelPad plugins
Locked
  • Author
  • Message
Offline
Posts: 8
Joined: Fri Aug 12, 2011 6:34 am

Post by wallywalters »

FeyFre and Vistor7, my thanks. I'm trying to get them working and learn from them both.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

MapNetDrive.js

Now the script can be run in AkelPad window or directly, in the command line.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

The following picture shows two windows of MapNetDrive.js script.
On the left - the script runs from AkelPad.
On the right - the script runs from command line.
Can someone explain to me why the buttons have a different shape and color?

Image

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ, it is probably because of DLLHELL ;) Akelpad.exe have own common controls manifest, where in dependencies requirement of Common controls 6.0 (with nice round corners and other shapes). But Wscript.exe does not have such manifest. Try to create one(borrow somewhere), name it wscript.exe.manifest and put near wscript.exe.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FeyFre
Excellent, this is what was needed!
I borrowed a manifest from Instructor (AkelPad.exe.manifest).
It works beautifully.
Thank you very much.

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ, don't forget to rename assembly (name attribute of assemblyIdentity tag). It could provoke unknown side-effects.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

FeyFre
What name would be appropriate? Could it be "wscript"?

Offline
Posts: 147
Joined: Fri Feb 08, 2008 6:41 pm
Location: British Columbia, Canada

XP Style Hacker - manifest file generator

Post by Surveyor »

I have run into similar problems with software (under Win XP SP3) which required a manifest file. You can generate your own using XP Style Hacker, available here:

http://www.softpedia.com/get/System/OS- ... cker.shtml

Its free and simple! The resulting (text) file may be edited using AkelPad, if desired. I believe that the target file should be wscript.exe (Windows\system32 folder under XP).

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

KDJ, I think it will be enough to name it as filename itself(i.e wscript.exe). You can prepend it with vendor name.

KDJ
Offline
Posts: 1949
Joined: Sat Mar 06, 2010 7:40 pm
Location: Poland

Post by KDJ »

Thank you Gentlemen.
The program which Surveyor gave, generated this file:

Code: Select all

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
  version="1.0.0.0"
  processorArchitecture="X86"
  name="CompanyName.ProductName.YourApp"
  type="win32"
/>
<description>Your application description here.</description>
<dependency>
  <dependentAssembly>
  <assemblyIdentity
    type="win32"
    name="Microsoft.Windows.Common-Controls"
    version="6.0.0.0"
    processorArchitecture="X86"
    publicKeyToken="6595b64144ccf1df"
    language="*"
  />
  </dependentAssembly>
</dependency>
</assembly>
[/color]
It looks like a template. You just need to enter own data - name in assemblyIdentity and description.

Offline
Posts: 88
Joined: Sun Jun 03, 2012 8:15 am

Post by Visitor7 »

Как лучше определить целое число и вернуть в виде числа?
Пока только так догадался, с кучей излишеств:
if ( (Math.floor(string) == string) && !isNaN(parseInt(string,10)) )
return parseInt(string,10);
Math.floor пустые строки с табуляцией и без переводит в "0", поэтому parseInt проверяю, он на пустые строки дает NaN.

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

Visitor7
Этот код посчитает строку "0000001111.00000" тоже целым числом (1111). По-моему это не вполне корректно. Или так и задумано?

Offline
Posts: 2247
Joined: Tue Aug 07, 2007 2:03 pm
Location: Vinnitsa, Ukraine

Post by FeyFre »

opk44
Ну "0000001111.00000" собственно математическому определению "целое число" соответствует. Также как и и запись 1.5e+1. Другое дело что физики скажут что "0000001111.00000" означает 0000001111 +/- 0.000005 а у них понятие "целого" в таких случаях уже не пляшет.

Offline
Posts: 88
Joined: Sun Jun 03, 2012 8:15 am

Post by Visitor7 »

opk44 wrote:код посчитает строку "0000001111.00000"
Я заметил. Мне нужно входные аргументы скрипта ограничить и в каком виде чел умудрится цифры ввести если удастся - не критично. Главное чтобы скрипт понял их правильно.
FeyFre wrote:физики скажут что "0000001111.00000" означает 0000001111 +/- 0.000005
В физике результат может быть 1234.123, а погрешность +/-25.4. А другой - с иной. Потом уже усредняют для красоты, статистики и в зависимости от того какая точность преследуется, ну мол напишем так 1200 +/-100, не соврем.
...
Вопрос снимается, я просто не знал что ((" " + 8 + "")/(2 * " " +2 -"")) == 4 а +" " === 0 ))) Зачем бороться с системой если она и так прекрасно работает. Странный язык. Взять тот же Math.floor, почему он кушает -15.6e2, 0x2F, но не кушает -0x2f и 0743, и нахрена нужно опознавание восьмиричной системы если двоичная была бы нужнее, а ее нет.

Offline
Posts: 874
Joined: Sat Jan 16, 2010 2:03 pm

Post by opk44 »

Visitor7 wrote:нахрена нужно опознавание восьмиричной системы если двоичная была бы нужнее, а ее нет.
Так уж и нет? Зачем же так безапелляционно. Сами же себе противоречите. В примере (parseInt(string,10)) Вы принудительно используете основание 10. С тем же успехом могли бы пользоваться ЛЮБОЙ системой счисления от 2 до 36! ;)

parseInt(numString, [radix]), где radix от 2 до 36.
Просто префиксы позволяют обойтись без второго параметра, лишь для трех оснований: 8, 10 и 16.

Пример:
WScript.Echo(parseInt('1111100111',2)); // "Результат" = 999
Locked