#1 2007-11-05 18:11

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

PascalScript: where is the InputBox() ?

Is there really no InputBox in PascalScript?
How can i ask the user for an parameter?

---

It seams PascalScript miss some features.
Is it much work for you to support WSH with VBS and/or JS language for ReNamer scripting, like PSPad does for editor scripting, as addition to PascalScript?


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#2 2007-11-06 11:39

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: where is the InputBox() ?

Stefan wrote:

It seams PascalScript miss some features.
Is it much work for you to support...

Or i have an better solution for you which save you time.
Could you provide an new rule
- which export the "new name" and store it into an temp file
- execute an external user application or script
- reload the temp file as "New Names"



Detail:
--------------------------------------------------------------------------------------------

New Rule dialog
"Execute      [..\AHK\AutoHotkey.exe         ][...]"
"Parameter   [C:\rename.ahk  "#"              ][...]"

(Where # is an placeholder for the tempfile ReNamer has generated, like C:\temp\ReNamer123.tmp)



If the User choose this rule and start Preview or Rename
then ReNamer should
* store the current "NewNames" in an temporary file  like C:\temp\ReNamer123.tmp
* show an MessageBox: "Please press OK if your script is finished"
* execute the user command: "AutoHotkey.exe C:\rename.ahk  C:\temp\ReNamer123.tmp"
* wait till the user press OK

If the user press OK
then ReNamer should
* reload the temp file "C:\temp\ReNamer123.tmp"
* and fill them in as "New Names"
--------------------------------------------------------------------------------------------




This way the user can decide which scripting language he wants to use:
VBS
JS
AutoHotkey
AutoIt
Editor with scripting support
even an Batch

----

I agree this could be a timing problem and the user could press OK to early.
But let this the user  decide.
We can also use an Message in our script which says us "Ready!"


--

Just an idea.
What do you think? roll


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#3 2007-11-06 13:11

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: PascalScript: where is the InputBox() ?

Get latest development version: ReNamerBeta.zip

I've added two new functions:

* function InputBox(const ACaption, APrompt, ADefault: String): String;
* function WideInputBox(const ACaption, APrompt, ADefault: WideString): WideString;

And for execution of 3-rd party tools you can use these two functions:

* function ExecuteProgram(const Command: string; WaitForProgram: Boolean): Cardinal;
* function ExecConsoleApp(const CommandLine: string; out Output: string): Cardinal;

Offline

#4 2007-11-06 17:34

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: where is the InputBox() ?

Thank you Denis big_smile

InputBox works

ReNamer_InputBox.PNG

var
  vUserInput: string;
begin
//                  InputBox(const ACaption, APrompt, ADefault: string): string;

vUserInput := InputBox('My Caption', 'The Description Prompt', 'Default string');

// your code here
end.




Now i try how i could use ExecuteProgram
(What is Cardinal??? ==> http://www.gnu-pascal.de/gpc/Cardinal.html )

Last edited by Stefan (2007-11-07 15:51)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2007-11-06 21:33

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: where is the InputBox() ?

How can i catch if the user pressed the [Cancel] button?

--

If vUserInput = IDCANCEL Then
SKIP Countinue Break GoTo

--

If NOT vUserInput = IDCANCEL Then

--

IDCANCEL 2 The user chose the Cancel button.

--

Thanks

-----------------------------------------------------------#
EDIT:

i found this info:

  if  bla     then
      begin
         blubb
         Break;
      end;


Perhaps Break; works here too?

If vUserInput = IDCANCEL Then
   Break;

i will test it someday
-----------------------------------------------------------#

Last edited by Stefan (2008-02-28 12:58)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#6 2007-11-12 12:22

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: PascalScript: where is the InputBox() ?

When user presses Cancel button, the dialog should return EMPTY string.

Is that any use for you?

Offline

#7 2007-11-12 12:55

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: where is the InputBox() ?

den4b wrote:

When user presses Cancel button, the dialog should return EMPTY string.

Is that any use for you?

Thank you for your answer.

> Is that any use for you?
Not really because i expected to cancel  the execution of the script or skip this name.
I just expected to get an "error level" which i could catch with an IF-Then as in VBscript.

And i got not an "EMPTY string" but the same as if i pressed OK. (at least with my script below)

Rename each file alone.pas to be prompted for each name to confirm or modify as new name:

// Rename each name alone.pas

var
  vUserInput: String;

begin

  vUserInput := InputBox('Rename FileName', 'Insert new FileName:', FileName);
    //If vUserInput = Cancel Then Continue; // means skip this file only
    //If vUserInput = Cancel Then BREAK;   //  to stop the whole script.

  FileName :=  vUserInput + WideExtractFileExt(FileName);

end.

-----------------

EDIT / UPDATE:


den4b wrote:

And for execution of 3-rd party tools you can use these two functions:

* function ExecuteProgram(const Command: string; WaitForProgram: Boolean): Cardinal;
* function ExecConsoleApp(const CommandLine: string; out Output: string): Cardinal;

Hi Denis, would you please explain how to use ExecConsoleApp(const CommandLine: string; out Output: string): Cardinal;

The syntax is different from ExecuteProgram:
1: for what is 'out' 'Output' ?
2: for 'CommandLine' i can't give them an parameter like ExecConsoleApp('some.cmd 3');     
3: i can't use relative paths like ExecConsoleApp('scripts\some.cmd 3');    Is this 'relative paths' function hard to implement?


Thanks

Last edited by Stefan (2007-11-18 22:39)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#8 2007-11-22 00:54

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: PascalScript: where is the InputBox() ?

Regarding InputBox() return... You can simply assume that if the returning string is EMPTY, then user pressed CANCEL button, because if user submits an EMPTY string then your new filename will be empty, so you have to break the script anyway. The question is... Do you really need to know if user pressed cancel button? In which case, a separate function will be required for that task.

You can use parameters in the ExecConsoleApp() function, but there are few things to be aware of. First, you should always use FULL path, and second, always surround path and parameters with inverted commas, for example: ExecConsoleApp("c:\program.exe" "param1" "param2", Output). This makes possible extraction of PDF and RAW tags, via 3-rd party command line tools, like demonstrated here: PDF meta tags and Date and Time from RAW images

P.S. Don't mind the "out" keyword, just treat it as "var". Variable passed will contain the output of the executed command.

Offline

#9 2007-11-22 21:35

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: PascalScript: where is the InputBox() ?

Thanks for answering.

den4b wrote:

Regarding InputBox() return...
You can simply assume that if the returning string is EMPTY, then user pressed CANCEL button,
because if user submits an EMPTY string then your new filename will be empty,

If i press cancel in my script above i got no empty string but the file name instead.
OK i will test more.
EDIT:
roll  Need the weekend to test it. Sorry to bother you and thanks for all your help.



so you have to break the script anyway.

Would you please show me how to break the script?  I mean i have seen this nowhere till now. And most commands from pascal didn't work.

vUserInput := InputBox.......
If vUserInput = '' Then
break? exit? or what?


With this i would have an work around:
vUserInput := InputBox.......
If vUserInput = 'STOP-IT' Then
exit



The question is... Do you really need to know if user pressed cancel button?
In which case, a separate function will be required for that task.

Yes this is the question. Maybe i would use this not that often.   Hmm, but an cancel button should cancel/end the script.
Maybe  for previewing  500 files i would/could ask the user (in an test phase) every 50 files if he want to end the execution.
I have to test more but i guees i like functions to read what the user have pressed: OK or Cancel.





You can use parameters in the ExecConsoleApp() function, ....

Need some time to think about this, thanks for the answer!


Stefan

Last edited by Stefan (2007-11-22 21:41)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#10 2007-12-07 13:25

den4b
Administrator
From: den4b.com
Registered: 2006-04-06
Posts: 3,374

Re: PascalScript: where is the InputBox() ?

I have more good news for you! smile

In the latest development version I've added two new functions:

function InputQuery(const ACaption, APrompt: string; var Value: string): Boolean;
function WideInputQuery(const ACaption, APrompt: WideString; var Value: WideString): Boolean;

They work exactly like InputBox/WideInputBox, but they will also return TRUE is user presses OK, and FALSE when user presses CANCEL.

Offline

Board footer

Powered by FluxBB