InFile

So you have written that new, must have program. Let us see it here.
User avatar
cogier
Site Admin
Posts: 672
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: InFile

Post by cogier » 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!

User avatar
BruceSteers
Posts: 441
Joined: Thursday 23rd July 2020 5:20pm

Re: InFile

Post by BruceSteers » Saturday 13th February 2021 4:01pm

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

:)
Wishing well
Bruce

If at first you don't succeed , try it differently.

01McAc
Posts: 64
Joined: Sunday 24th January 2021 8:25pm

Re: InFile

Post by 01McAc » Tuesday 09th March 2021 3:16pm

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?

User avatar
cogier
Site Admin
Posts: 672
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: InFile

Post by cogier » Tuesday 09th March 2021 3:58pm

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.

01McAc
Posts: 64
Joined: Sunday 24th January 2021 8:25pm

Re: InFile

Post by 01McAc » Tuesday 09th March 2021 5:12pm

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

User avatar
cogier
Site Admin
Posts: 672
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: InFile

Post by cogier » Tuesday 09th March 2021 5:35pm

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.

Post Reply