Page 4 of 4

Re: InFile

Posted: Saturday 13th February 2021 10:57am
by cogier
BruceSteers wrote: Saturday 13th February 2021 1:01am Oh and recusive , typo on long arg :roll:
And 'folder' instead of 'folders' and '.*jepg' instead of 'jpeg, all fixed. Nice video too!

Re: InFile

Posted: Saturday 13th February 2021 4:01pm
by BruceSteers
cogier wrote: Saturday 13th February 2021 10:57am
BruceSteers wrote: Saturday 13th February 2021 1:01am 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 :)
https://gitlab.com/bsteers4/scripted

:)

Re: InFile

Posted: Tuesday 9th March 2021 3:16pm
by 01McAc
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
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
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?

Re: InFile

Posted: Tuesday 9th March 2021 3:58pm
by cogier
Create a new Gambas Project

Copy the GetFiles class from InFiles into your new program then in FMain run this code: -
Public sFolder As String = User.Home
Public bRecursive As Boolean = False
Public sPattern As String = "*"
TaskGetFiles As Task

Public Sub Form_Open()

  TaskGetFiles = New GetFiles As "TaskGetFiles"       'Creates a new instant of the 'Task' and runs it

End

Public Sub TaskGetFiles_Kill()                        'When the 'Task' is finished this will catch the event

  Dim sFileList As String[] = TaskGetFiles.Value
  Dim iLoop As Integer

  For iLoop = 0 To sFileList.Max
    Print sFileList[iLoop]
  Next

End
Hopefully that will help. The line TaskGetFiles = New GetFiles As "TaskGetFiles" causes the 'Task' to run.

Re: InFile

Posted: Tuesday 9th March 2021 5:12pm
by 01McAc
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:
' Gambas class file

'MyTask_FTS.class

Inherits Task


Public Function Main() As Variant    'DB_update_FTS() As Variant
  
  Dim DBS As New Cls_SQL_DataBase
  Dim $Rec As Result
  Dim $Query, $QueryUpdate As String 
  Dim sToday As String = Format(Now(), AV.FormatDBDateNoTime)
    
  'Debug sToday
  
  $QueryUpdate = "UPDATE App_variables SET Val='" & sToday & "' WHERE Var='LastCreateFTS'"
  'Debug $Query
  
  
    $Query = "SELECT * FROM App_variables WHERE Var='LastCreateFTS'"
    $Rec = DBS.$Con.Exec($Query)
    If Not $Rec.Available Then 
      'Message("No variable defined")
      Return False
    Endif
  
    If sToday > $Rec!Val Then
      'Debug "Action: Create Virt. Table:  --> sToday '" & sToday & "' ist größer als der letzte Eintrag: '" & $Rec!Val & "'"
      DBS.Refresh_FTS
      $Rec = DBS.$Con.Exec($QueryUpdate)
      Wait  
    Else
      'Debug "No activities required sToday '" & sToday & "' ist NICHT größer oder jedoch gleich letzter Eintrag: '" & $Rec!Val & "'"
    Endif
    Return True
End

Re: InFile

Posted: Tuesday 9th March 2021 5:35pm
by cogier
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.

Re: InFile

Posted: Thursday 19th August 2021 12:02am
by BruceSteers
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 :)

DBus["session://org.freedesktop.FileManager1"]["/org/freedesktop/FileManager1", "org.freedesktop.FileManager1"].ShowItems([sFileName], "SHF")
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...
Public Sub Main()
 OpenFM("/path/to/file")
End


Public Sub OpenFM(sFile As String)
If Not Left(sFile, 7) = "file://" Then sFile = "file://" & sFile
  If DBus.Session.Applications.Exist("org.freedesktop.FileManager1") Then
    DBus["session://org.freedesktop.FileManager1"]["/org/freedesktop/FileManager1", "org.freedesktop.FileManager1"].ShowItems([sFile], "SHF")
  Else

  ' Other code here

  Endif
End

Sorry fella I assumed that command would be on all desktops :(

Re: InFile

Posted: Thursday 19th August 2021 4:41pm
by cogier
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?

Image

Re: InFile

Posted: Thursday 19th August 2021 6:24pm
by BruceSteers
cogier wrote: Thursday 19th August 2021 4:41pm 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?

Image
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.