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 mishem » Mon Dec 09, 2013 8:26 am

What is the problem ?

I just do not understand why at all?
If you want to know the number of items in the list, it must be done at the end.
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 8:42 am

SetVar "[InputMaskConvert]" "All image files supported|*.BMP;*.JPG;*.PNG;*.MNG;*.JNG;................


It is not clear at all that that ka can search?

Math "[ListNbr]+[FilesCount]-[FilesCount]" "-1" "[TotalNbrList]"

[ListNbr]=10
[FilesCount]=1
10+1-1 =10

Totally unnecessary action

If I write :
CODE: SELECT ALL
Math "[ListNbr]-[FilesCount]" "-1" "[TotalNbrList]"

The result is false...


Correctly.
Likely to list fewer items than the found files.
[ListNbr]=10
[FilesCount]=5000
10-5000=-4990
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 8:55 am

Code: Select all
SetVar "[InputMaskConvert]" "*.BMP;*.IMG;*.PBM;*.PAM;*.PFM;*.BSI;*.CIF;*.DAGSKY;*.DAGTEXTURE;*.DDS;*.GIF;*.JNG;*.JPG;*.JP2;*.MNG;*.PCX;*.PGM;*.PNG;*.PPM;*.PSD;*.TGA;*.TIF;*.XPM"


It is suitable for zmFindFiles
But not suitable for FileList
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 9:02 am

mishem:
>It is not clear at all that that ka can search?

This is a custom file mask that works with npImgs plugin. If you do not have this plugin, this mask is useless.
For me, this mask is perfect.

The problem is not there, since everything works with a directory of 100 images. The problem lies elsewhere...

>[ListNbr]=10
[FilesCount]=1
10+1-1 =10

Yes, but if i write :
Code: Select all
Math "[ListNbr]-[FilesCount]" "-1" "[TotalNbrList]"

The result is false...
I can count to 10 and I assure you that result is false.

>Correctly.
Likely to list fewer items than the found files.
[ListNbr]=10
[FilesCount]=5000
10-5000=-4990

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

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 9:10 am

This is a custom file mask that works with npImgs plugin.

In Russian think that I could explain it. With googly is a problem.
:)
Mask in such a way as you acceptable to open \ Save the file.
Not acceptable for the search.
How do you find the 100 images, I do not know.
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 9:14 am

I do not find only 100 images, I find even 5000.
The problem occurs after found 5000... Not before !
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 9:20 am

mishem wrote:
This is a custom file mask that works with npImgs plugin.

In Russian think that I could explain it. With googly is a problem.
:)
Mask in such a way as you acceptable to open \ Save the file.
Not acceptable for the search.
How do you find the 100 images, I do not know.


Yes you're right. For add a directory, it is not necessary to give a mask file also evolved. But it does not change the problem... But thanks :)
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 9:50 am

mishem wrote:
What is the problem ?

I just do not understand why at all?
If you want to know the number of items in the list, it must be done at the end.


You're wrong.
If the calculation is not done 2 times, then rejected files (doubles) are counted as added files in the list.
If they are denied, they should avoid.
Strange to but if I write :
Code: Select all
Math "[ListNbr]-[FilesCount]" "-1" "[TotalNbrList]"

The result is false.

And if i write :
Code: Select all
Math "[ListNbr]+[FilesCount]-[FilesCount]" "-1" "[TotalNbrList]"

The result is good.
Must take into account the rejected files.

But this does not solve any problem...
In the Neo debugger, there is an action that runs very fast, like an endless loop at the end of the script. I can't not stop (pause) the debugger, he refuses.
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 9:51 am

The problem occurs after found 5000... Not before !


Have you tried to run the code that I wrote to you?
zmFunctions
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 10:06 am

This is version 1.0b ?
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 10:11 am

ListBoxFindItem "SourceImagesListBox" "[SelectedDir]\[FilePaths[I]]" "[Result]"

[SelectedDir]=This is the path to the selected folder
[FilePaths[I]]=This is the full path to the found image

For example:
[SelectedDir]=C:\Documents and Settings\All Users\Folder
[FilePaths[I]]=C:\Documents and Settings\All Users\Folder\image.bmp

[SelectedDir]\[FilePaths[I]] = C:\Documents and Settings\All Users\Folder\C:\Documents and Settings\All Users\Folder\image.bmp
....................................


Math "[ListNbr]+[FilesCount]" "-1" "[TotalNbrList]"

[ListNbr]=Items on the list!
[FilesCount]=Found files!!!!

................................
ExtractFileName "[FilePaths[I]]" "[FileName]"
Why?
This variable is constantly changing in the loop!!!
..............................
Math "[ListNbr]+[FilesCount]-[FilesCount]" "-1" "[TotalNbrList]"
Why do it at all?
Variable [TotalNbrList] does not appear anywhere.
...............................
If "[Result]" "<>" "0"
AlertBox "[AppTitle]" "You have selected [FilesCount] file(s) already in the list.|[AppTitle] will not add these files."
EndIf
It is also completely unnecessary.
Result only for the last record found.

..................................
Everything. I'm tired of knocking on an open door.
:)
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 10:12 am

This is version 1.0b ?

Yes
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby UltraVox » Mon Dec 09, 2013 10:34 am

ExtractFileName "[FilePaths[I]]" "[FileName]"
Why?
This variable is constantly changing in the loop!!!


And then? I want to display each file added to the outside of this function. It is forbidden? It is not because you do not see any application that you must deduct that command lines are useless.

Math "[ListNbr]+[FilesCount]-[FilesCount]" "-1" "[TotalNbrList]"
Why do it at all?
Variable [TotalNbrList] does not appear anywhere.


You deduct very anything.
[TotalNbrList] is a variable displayed above the list. If the calculation is not performed, the user does not know how many elements there. Please, stop deduct anything.

I tried your script and nothing happens. I left empty the Mask fields.

Everything. I'm tired of knocking on an open door.
:)


In this case, do not intervene. If you are not able to give an explanation without ennerver is that you have nothing to do on this forum.
Thanks for help
UltraVox
 
Posts: 419
Joined: Sat Jul 28, 2007 11:14 am
Location: France

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 11:27 am

I tried your script and nothing happens. I left empty the Mask fields

Tried his example. Lots of time is spent on StrParse.

Replaced by Strparse hpwLine. Plugin hpwControl.
Found 18650 images and added to the list.
Long true.

Code: Select all
FolderBox "Select your images directory :" "[SelectedDir]"

If "[SelectedDir]" "=" ""
  AlertBox "[AppTitle]" "Please, choose a valid directory."
  Return
Else
............Mask - a mask file names (without paths) or file extensions.

............For example: NeoBook.exe or *. Txt.

............You can search on several names or file extensions, in this case, file names or extensions separated by semicolons.

............To find all types of files, this argument can be left blank.
  SetVar "[InputMaskConvert]" "*.BMP;*.IMG;*.PBM;*.PAM;*.PFM;*.BSI;*.CIF;*.DAGSKY;*.DAGTEXTURE;*.DDS;*.GIF;*.JNG;*.JPG;*.JP2;*.MNG;*.PCX;*.PGM;*.PNG;*.PPM;*.PSD;*.TGA;*.TIF;*.XPM"
  zmFindFiles "[InputMaskConvert]" "[SelectedDir]" "SubFolders" "" "[FilesinFolder]"
.  StrParse "[FilesinFolder]" "[#13]" "[FilePaths]" "[FilesCount]"
 Loop "1" "[zmFindFilesCount]" "[I]"
 hpwLine "[FilesinFolder]" "[I]" "[FilePaths]"
   ListBoxFindItem "SourceImagesListBox" "[FilePaths]" "[Result]"
    If "[Result]" "=" "0"
       ListBoxAddItem "SourceImagesListBox" "0" "[FilePaths]"
    EndIf
  EndLoop
EndIf
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

Re: Search and Replace text in a file

Postby mishem » Mon Dec 09, 2013 11:37 am

I want to display each file added to the outside of this function.

Now I understand.

If the calculation is not performed, the user does not know how many elements there.

It may be better to display variable [i]?
or
SetVar "[TotalNbrList]" "[FilesCount]-[i]"
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm

PreviousNext

Return to NeoBook Action Commands

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron