InFile

Post

Posted
Rating:
#26
Banned

PJBlack said

why not integrate bruces scripted into charlies infile or vice versa?

All things are possible :)

Can you make it take args Charlie?

I was thinking about doing something plugin like with ScriptEd
I love "External Tools" in Pluma, very handy , was thinking of something similar.

InFile could be easily added to a customisable list of tools.
would be good to auto-fill the fields and search by adding some args at runtime.
gb.args can take the effort out of it :)
Online now: No Back to the top

Post

Posted
Rating:
#27
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
..would be good to auto-fill the fields and search by adding some args at runtime.

OK here is a start.

<COLOR color="#FF0000">WARNING</COLOR> This is a development version of the program

Code

./InFile.gambas --help

Will get you: -

Code

Usage: InFile <options> <arguments>

Options:
 -p --pattern <Pattern>                 File pattern to search e.g.'*.jpg,*.jepg'
 -s --search <Search>                   Text to search for
 -f --folder <Folder>                   Folder to search e.g.'~/pictures'
 -i --ignorecase <IgnoreCase>           Ignore the case when searching
 -R --recusive <Recursive>              Search in the sub folder of 'Folder'
 -V --version                           Display version
 -h --help                              Display this help
 
A sample command: -

Code

./InFile.gambas -p *.class -s WebView -f ~/Dropbox/gambas -i t -R t

The -i and -R commands need to start with "t" to be True. If it starts with anything else its False, but it must contain some text. I haven't worked out how to set it up without text - YET!.

Attachment
Online now: No Back to the top

Post

Posted
Rating:
#28
Banned

cogier said

..would be good to auto-fill the fields and search by adding some args at runtime.

OK here is a start.

<COLOR color="#FF0000">WARNING</COLOR> This is a development version of the program

Code

./InFile.gambas --help

Will get you: -

Code

Usage: InFile <options> <arguments>

Options:
 -p --pattern <Pattern>                 File pattern to search e.g.'*.jpg,*.jepg'
 -s --search <Search>                   Text to search for
 -f --folder <Folder>                   Folder to search e.g.'~/pictures'
 -i --ignorecase <IgnoreCase>           Ignore the case when searching
 -R --recusive <Recursive>              Search in the sub folder of 'Folder'
 -V --version                           Display version
 -h --help                              Display this help
 
A sample command: -

Code

./InFile.gambas -p *.class -s WebView -f ~/Dropbox/gambas -i t -R t

The -i and -R commands need to start with "t" to be True. If it starts with anything else its False, but it must contain some text. I haven't worked out how to set it up without text - YET!.

try this..  :)

Code (gambas)

  1.  
  2.   bArgCase = Args.Has("i", "ignorecase", "Ignore the case when searching")
  3.   bArgRecursive = Args.Has("R", "recusive", "Search in the sub folder of 'Folder'")
  4.  
  5.  
Note: change to Boolean not string.


Another useful thing is getting leftover args with Args.End
If once you have catered for args using Get() and Has() calls you can use the following to read any other args (it handy if you want to pass multiple args like a bunch of file names , search strings, etc withoug having to prefix them all)

Code (gambas)

  1.  
  2.  Dim sTheRestOfTheArgs As String[] = Args.End
  3.  
  4.  


Awesome stuff :)
I almost have a "External Tools" like thing going with my Editor now.
i can parse file name / file dir / selected text or all text to any shell command so should be able to select some text then search.
just having an issue with my variables at mo..
Online now: No Back to the top

Post

Posted
Rating:
#29
Banned
Here it is working a treat :)

I had to fix the -i -R flag stuff.
i changed the vars to boolean and used Args.Has()

I've added it to my "External Tools" list of commands so it searches my gambas source code folder for selected text in class and module files.
(attachment removed)

It's quick :)
<VIDEO content="http://bws.org.uk/images/screenrecord-2021-02-13_00.46.31.mp4">[video]
[/video]</VIDEO>
Online now: No Back to the top

Post

Posted
Rating:
#30
Banned
Oh and recusive ,  typo on long arg    :roll:
Online now: No Back to the top

Post

Posted
Rating:
#31
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’

BruceSteers said

Oh and recusive ,  typo on long arg    :roll:

And 'folder' instead of 'folders' and '.*jepg' instead of 'jpeg, all fixed. Nice video too!
Online now: No Back to the top

Post

Posted
Rating:
#32
Banned

cogier said

BruceSteers said

Oh and recusive ,  typo on long arg    :roll:

And 'folder' instead of 'folders' and '.*jepg' instead of 'jpeg, all fixed. Nice video too!

Haha , isn't it always the way  :lol:

I thought you may like the vid , it's good to see it all in action :)
you should be able to use InFile now with Pluma "External tools" too.

I've uploaded ScriptED with my "External tools" addition now.
cheers for the nudge , been meaning to do that for a while :)
Bruce Steers / scripted · GitLab

:)
Online now: No Back to the top

Post

Posted
Rating:
#33
Regular
01McAc is in the usergroup ‘Regular’
I had a look in your InFile project and have a question re the task GetFiles. What exactly triggers/runs the function Main() in GetFiles.class? The declaration

Code (gambas)

  1. TaskGetFiles = New GetFiles As "TaskGetFiles"       ?
I am asking because I try to adopt the tasks into my project. I exactly copied the task related code and implemented it into my project. Nothing starts the function Main(). I always need an explicit command like

Code (gambas)

  1. TaskGetFiles.Main()
Otherwise the task won't run. I suppose the problem sits in front of the computer as usual.
So the interesting question for me is what triggers/runs the function Main() in GetFiles.class in FMain.class?
Online now: No Back to the top

Post

Posted
Rating:
#34
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
Create a new Gambas Project

Copy the GetFiles class from InFiles into your new program then in FMain run this code: -

Code (gambas)

  1. Public sFolder As String = User.Home
  2. Public bRecursive As Boolean = False
  3. Public sPattern As String = "*"
  4. TaskGetFiles As Task
  5.  
  6. Public Sub Form_Open()
  7.  
  8.   TaskGetFiles = New GetFiles As "TaskGetFiles"       'Creates a new instant of the 'Task' and runs it
  9.  
  10.  
  11. Public Sub TaskGetFiles_Kill()                        'When the 'Task' is finished this will catch the event
  12.  
  13.   Dim sFileList As String[] = TaskGetFiles.Value
  14.   Dim iLoop As Integer
  15.  
  16.   For iLoop = 0 To sFileList.Max
  17.     Print sFileList[iLoop]
  18.   Next
  19.  

Hopefully that will help. The line TaskGetFiles = New GetFiles As "TaskGetFiles" causes the 'Task' to run.
Online now: No Back to the top

Post

Posted
Rating:
#35
Regular
01McAc is in the usergroup ‘Regular’
Thanks for the quick reply. Your code is working very well in a new project. I copied and change the code into my project and…. drum roll… nothing happened.
To make long story short:
The minute I removed the debug code in my task function, it works pretty well. Weird  :idea:

Code (gambas)

  1. ' Gambas class file
  2.  
  3. 'MyTask_FTS.class
  4.  
  5.  
  6.  
  7. Public Function Main() As Variant    'DB_update_FTS() As Variant
  8.  
  9.   Dim DBS As New Cls_SQL_DataBase
  10.   Dim $Rec As Result
  11.   Dim $Query, $QueryUpdate As String
  12.   Dim sToday As String = Format(Now(), AV.FormatDBDateNoTime)
  13.    
  14.   'Debug sToday
  15.  
  16.   $QueryUpdate = "UPDATE App_variables SET Val='" & sToday & "' WHERE Var='LastCreateFTS'"
  17.   'Debug $Query
  18.  
  19.  
  20.     $Query = "SELECT * FROM App_variables WHERE Var='LastCreateFTS'"
  21.     $Rec = DBS.$Con.Exec($Query)
  22.     If Not $Rec.Available Then
  23.       'Message("No variable defined")
  24.       Return False
  25.     Endif
  26.  
  27.     If sToday > $Rec!Val Then
  28.       'Debug "Action: Create Virt. Table:  --> sToday '" & sToday & "' ist größer als der letzte Eintrag: '" & $Rec!Val & "'"
  29.       DBS.Refresh_FTS
  30.       $Rec = DBS.$Con.Exec($QueryUpdate)
  31.       Wait  
  32.     Else
  33.       'Debug "No activities required sToday '" & sToday & "' ist NICHT größer oder jedoch gleich letzter Eintrag: '" & $Rec!Val & "'"
  34.     Endif
  35.     Return True
Online now: No Back to the top

Post

Posted
Rating:
#36
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
I am not good with Databases, so I'm not qualified to comment on your code.

The problem with Task is that if it does nothing you can't see what's gone wrong. If you look at the second Task in InFile (SearchFile.class) on line 27 there is a Print statement. You can see this in your main program by using Task_Read(), see line 400 in FMain. In this case it returns the amount of files that have been searched, but you can Print anything helpful and return it to your program to get an idea of what's going on.
Online now: No Back to the top

Post

Posted
Rating:
#37
Banned
Hey Charlie……

I've been checking out Dbus  "gb.dbus"
Your filemanager opening function could possibly be done better with Dbus :)
I just tried the following on Cinnamon and it worked a treat :)

Code (gambas)

  1.  
  2. DBus["session://org.freedesktop.FileManager1"]["/org/freedesktop/FileManager1", "org.freedesktop.FileManager1"].ShowItems([sFileName], "SHF")
  3.  

no need to use filmeanager searching at all.

Notes
"SHF" is just an id string, can be anything
sFileName is full file path (multiple filenames can be given)


Darn , sorry dude seems it only works on Cinnamon and MATE (plus on mate it neede a file:// prefix)

So code more like this…

Code (gambas)

  1. Public Sub Main()
  2.  OpenFM("/path/to/file")
  3.  
  4.  
  5. Public Sub OpenFM(sFile As String)
  6. If Not Left(sFile, 7) = "file://" Then sFile = "file://" & sFile
  7.   If DBus.Session.Applications.Exist("org.freedesktop.FileManager1") Then
  8.     DBus["session://org.freedesktop.FileManager1"]["/org/freedesktop/FileManager1", "org.freedesktop.FileManager1"].ShowItems([sFile], "SHF")
  9.   Else
  10.  
  11.   ' Other code here
  12.  
  13.  
  14.  

Sorry fella I assumed that command would be on all desktops :(
Online now: No Back to the top

Post

Posted
Rating:
#38
Avatar
Guru
cogier is in the usergroup ‘Guru’
cogier is in the usergroup ‘GambOS Contributor’
I have just been having a look at D-Bus. I just need to go into a darkened room for an hour! Am I any wiser - Er.. NO!

There is a program called D-feet (available from the Ubuntu Repos) that shows all the available connections on the D-Bus.

Have you created an example program in Gambas that will demonstrate what can be done with this?

<IMG src="https://www.cogier.com/gambas/D-feet.png"> </IMG>
Online now: No Back to the top

Post

Posted
Rating:
#39
Banned

cogier said

I have just been having a look at D-Bus. I just need to go into a darkened room for an hour! Am I any wiser - Er.. NO!

There is a program called D-feet (available from the Ubuntu Repos) that shows all the available connections on the D-Bus.

Have you created an example program in Gambas that will demonstrate what can be done with this?

<IMG src="https://www.cogier.com/gambas/D-feet.png"> </IMG>

No I didn't , there is one on the Farm though made by Fabien Bodard and Benoît Minisini.

I've attached it here , this version i tweaked in 2 ways.
1. you only have to single click (as opposed to doubleclick) the left hand list to populate the right hand list
2. if you doubleclick a command in the right list it copies the command to the clipboard in a way you can use it (almost).

It was tricky finding the right application name/path/interface with dbus until i added the doubleclick feature :)

I've mostly been learning DBus by loooking for what commands i have in the DBus_Explorer then googling the application for command reference.
Online now: No Back to the top
1 guest and 0 members have just viewed this.