Source language: Translate to:

Search and Replace text in a file

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Re: Search and Replace text in a file

Postby UltraVox » Thu Dec 05, 2013 8:05 am

I confirm. :roll:

I missed this to understand clearly :

Code: Select all
ExtractFileName "[FilePaths[I]]" "[FileName]"
      ChangeFileExt "[FileName]" ".gif" "[FileName]"
      npImgConvert "[FilePaths[I]]" "[PubDir]Target\[FileName]" "[Result]"


Because without filenames and without the output format, I understood nothing ! :mrgreen:

THANK YOU A THOUSAND TIMES !
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 9:39 am

Hello,

"[FilePaths]" is the variable which contain the list of input files in the sample. The first thing I made is to iterate over these files. Think that the output file names do not exists, and we based these on the input file names. So we extract the file names and change their extensions to the format we want to convert, in this case ".gif". So the "output format" is defined by the target file extensions: in this case the input images are converted to ".gif", but we can change it to any of the supported formats.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby UltraVox » Thu Dec 05, 2013 10:04 am

It's already done David, and everything works perfectly !

Code: Select all
If "[SourceImagesListBox]" "=" ""
  AlertBox "[AppTitle]" "Please select some source images from the list."
Else
  StrParse "[SourceImagesListBox]" "[#13]" "[FilePaths]" "[FilePathsCount]"
  Loop "1" "[FilePathsCount]" "[I]"
    ExtractFileName "[FilePaths[I]]" "[FileName]"
    ChangeFileExt "[FileName]" "[Ext]" "[FileName]"
    npImgConvert "[FilePaths[I]]" "[ConvertionDirectory]\[FileName]" "[Result]"
  EndLoop
EndIf


I will come back to you to integrate progress bar during conversions.
Something tells me that you have a plugin for that ? ;)
I'll try with the ones I already...

Thanks again !
:mrgreen:
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 10:19 am

Hello,

Good to know finally you got it. We can use here two progress bars: one for the total of images to be converted, and another for the total of image formats. Maybe you like to try my npBars plugin:

Image
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby UltraVox » Thu Dec 05, 2013 10:38 am

Ok David I tests with npBars.
If you have any recommendations for use to me, this is now.
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 10:42 am

Hello,

UltraVox wrote:Ok David I tests with npBars.
If you have any recommendations for use to me, this is now.


It's not more difficult to use. Basically you need to establish a "max" value for the progress bar. Then you can change the "position" of the progress when needed. Supose we have 10 input images: we can establish the progress bar "max" to 10, and then, increment the position by 1 when convert an image. At the end of the task the task bar appear plenty, because we pass al the steps between 1 to 10.

The better I can say is you can take a look at the plugin sample, that you know is included once you install the plugin. Remember these samples are placed into your "User documents" folder, under a directory named "NeoPlugins". If you take a look at your Windows Start Menu you can found a shortcut to this directory.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby UltraVox » Thu Dec 05, 2013 11:08 am

Yes, but it is easy with a TrackBar. It is less easy with the npImgs process convertion...
Look at my code above and guide me, you do not spend two days with it, please. :)

I created a CustomWindow with a Rectangle named "RectProgBar".

What variables should I put in npBarSetPos ?
A example for my code would be welcome ;)
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 11:54 am

Hello,

Take a look at this sample again:

http://www.neoplugins.com/?download/npimgconvert.zip

Now the sample include the use of a progress bar.
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 12:19 pm

Hello,

Take a look at this video I make using the above sample:



** And CamStudio. ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby UltraVox » Thu Dec 05, 2013 12:57 pm

Ok this is cool ! It works fine in my app.
Thank you for this example, very demonstrative ;)

And video too haha :)

I will end up buying all your plugins !
With me, you do not work for nothing :roll:

Thanks again :)
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Thu Dec 05, 2013 12:59 pm

You're welcome. ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Search and Replace text in a file

Postby UltraVox » Fri Dec 06, 2013 12:26 am

David,

Is it possible to cancel a convertion process as it occurs ? For example, with a Cancel button that would stop the convertion...

And also, do you know how to select all items in a list by pressing a button ?
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby CN_Iceman » Fri Dec 06, 2013 2:04 am

Hi.
One way is to use the Control Action "ExitLoop" (Exit the current Loop/EndLoop block. Execution continues with the Action following the next EndLoop statement.)

For example, you can create a Cancel Button with this code when pressed:
SetVar "[Cancel_Activated]" "YES"

Now in the convert images loop you can insert this code:
Code: Select all
Loop "1" "[FilePathsCount]" "[I]"
.-------- THIS IS THE NEEDED CODE --------------
  If "[Cancel_Activated]" "=" "YES"
      ExitLoop
  EndIf
.------------------------------------------------------
  ExtractFileName "[FilePaths[I]]" "[FileName]"
  ChangeFileExt "[FileName]" "[Ext]" "[FileName]"
  npImgConvert "[FilePaths[I]]" "[ConvertionDirectory]\[FileName]" "[Result]"
EndLoop


It is very easy.

Greetings.
Greetings/Saludos, Jose.
www.icemansoft.es
User avatar
CN_Iceman
 
Posts: 297
Joined: Tue Mar 01, 2011 11:04 am
Location: España

Re: Search and Replace text in a file

Postby UltraVox » Fri Dec 06, 2013 2:18 am

Thank you CN_Iceman !
Really good...
I had not used NeoBook long time and it is sometimes difficult to remember things as simple...

But I learned and I remember all those good things. Because once I have an example, it is much better ;)

Thanks again !
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby dec » Fri Dec 06, 2013 3:03 am

Hello,

Jose reply to the first question and is good. I also want to obtain the reply for the second question:

UltraVox wrote:And also, do you know how to select all items in a list by pressing a button ?


... Just now I can't thinking on an appropiate solution... ;)
.
Enhance your NeoBook applications!
.
58 plugins, 1131 actions and 233 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

PreviousNext

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests