Sharing: after searching the Play Store, I found the Filex application (freeware), which reads sqlite files (the best I found). I wanted to access a project's sqlite.db, run queries, and save them for future use. I came to the conclusion that it would be faster to create views in sqlite.db using, for example, Sqlite Expert Personal (freeware), than to create a query directly in Filex. Then, with the help of ChatGPT, I generated the views. Below is an example of a view script and a screen with the data displayed by the view, which is the same as what Filex shows on a cell phone. Just copy the sqlite.db to a folder on your phone. It's not the best of all worlds, but it's a simple way to have synthetic analytical information from an MVD project on your cell phone!


WITH
  [subquery] AS(
    SELECT 
           STRFTIME ("%Y", [data]) AS [ano], 
           [lancamento_all_view].[id_tipo_operacao], 
           CASE WHEN [lancamento_all_view].[id_tipo_operacao] = 1 THEN "Receitas" ELSE "Despesas" END AS "Operacao", 
           [lancamento_all_view].[id_categoria], 
           [lancamento_all_view].[categoria], 
           CASE WHEN [id_tipo_operacao] = 1 THEN SUM ([entrada] - [saida]) ELSE SUM ([saida] - [entrada]) END AS [valor]
    FROM   [lancamento_all_view]
    WHERE  [lancamento_all_view].[id_categoria] <> 0
             AND [lancamento_all_view].[ocultar_mining] = 0
    GROUP  BY
              [lancamento_all_view].[id_tipo_operacao], 
              [lancamento_all_view].[categoria], 
              [ano]
  ),
  [category_totals] AS(
    SELECT 
           [categoria], 
           SUM ([valor]) AS [total_valor_categoria]
    FROM   [subquery]
    GROUP  BY [categoria]
  ),
  [cumulative_totals] AS(
    SELECT 
           [a].[ano], 
           [a].[id_tipo_operacao], 
           [a].[Operacao], 
           [a].[categoria], 
           [a].[valor], 
           (SELECT SUM ([b].[valor])
           FROM   [subquery] [b]
           WHERE  [b].[categoria] = [a].[categoria]
                    AND [b].[ano] <= [a].[ano]) AS [acumulado]
    FROM   [subquery] [a]
  ),
  [total_receitas] AS(
    SELECT 
           NULL AS [ano], 
           "Total Receitas" AS [Operacao], 
           NULL AS [categoria], 
           SUM ([valor]) AS [valor], 
           SUM ([valor]) AS [acumulado], 
           NULL AS [part%], 
           NULL AS [mini_grafico]
    FROM   [subquery]
    WHERE  [id_tipo_operacao] = 1
  ),
  [total_despesas] AS(
    SELECT 
           NULL AS [ano], 
           "Total Despesas" AS [Operacao], 
           NULL AS [categoria], 
           SUM ([valor]) AS [valor], 
           SUM ([valor]) AS [acumulado], 
           NULL AS [part%], 
           NULL AS [mini_grafico]
    FROM   [subquery]
    WHERE  [id_tipo_operacao] = 2
  ),
  [main_query] AS(
    SELECT 
           [subquery].[ano], 
           [subquery].[Operacao], 
           [subquery].[categoria], 
           PRINTF ('%.2f', [subquery].[valor]) AS [valor], 
           PRINTF ('%.2f', [cumulative_totals].[acumulado]) AS [acumulado], 
           PRINTF ('%.2f', ([subquery].[valor] / [category_totals].[total_valor_categoria]) * 100) AS [part%], 
           SUBSTR ('██████████████████████████████████████████████████████', 1, ROUND (([subquery].[valor] / [category_totals].[total_valor_categoria]) * 50)) || " (" || [subquery].[id_categoria] || ")" AS [mini_grafico], 
           [subquery].[id_categoria]
    FROM   [subquery]
           JOIN [category_totals] ON [subquery].[categoria] = [category_totals].[categoria]
           JOIN [cumulative_totals] ON [subquery].[ano] = [cumulative_totals].[ano]
                AND [subquery].[categoria] = [cumulative_totals].[categoria]
                AND [subquery].[id_tipo_operacao] = [cumulative_totals].[id_tipo_operacao]
  ),
  [blank_lines] AS(
    SELECT DISTINCT 
                    NULL AS [ano], 
                    NULL AS [Operacao], 
                    [categoria], 
                    NULL AS [valor], 
                    NULL AS [acumulado], 
                    NULL AS [part%], 
                    NULL AS [mini_grafico], 
                    [id_categoria]
    FROM   [main_query]
  )
SELECT 
       [ano], 
       [Operacao], 
       [categoria], 
       [valor], 
       [acumulado], 
       [part%], 
       [mini_grafico]
FROM   (SELECT 
               [ano], 
               [Operacao], 
               [categoria], 
               [valor], 
               [acumulado], 
               [part%], 
               [mini_grafico], 
               [id_categoria], 
               0 AS [sort_order]
        FROM   [main_query]
        UNION ALL
        SELECT 
               '***********' AS [ano], 
               '***********' AS [Operacao], 
               '***********' AS [categoria], 
               '***********' AS [valor], 
               '***********' AS [acumulado], 
               '***********' AS [part%], 
               '***********' AS [mini_grafico], 
               [id_categoria], 
               1 AS [sort_order]
        FROM   [blank_lines])
ORDER  BY
          [id_categoria],
          [sort_order],
          [ano],
          [Operacao]

102

(8 replies, posted in General)

sparrow wrote:

Hi all,

Several times on the forum questions appeared on the topic of various indicators for displaying information.
There are no built-in indicators.
This program is a demonstration of creating and using indicators (in this case circular ones) using MVD.
The script contains four procedures, each of which is responsible for its own indicator. All indicators work,
just some are slow (as intended). The first procedure can be called universal. The remaining three indicators
were created based on this procedure.
The procedure allows you to set the display angles of the scale, the range of scale values, scaling values, color
marks on the scale, change the direction of the scale reading and arrow movement, change the size of the
indicator, set the anchor point on the form, etc. . Knowing where to tweak, you can configure it more flexibly.
This procedure is already the second version. The first version was tied to user-created panels on the form.
On the one hand, this made it easier to place and link to a place, on the other hand, it did not allow indicators
to be partially superimposed on other elements or fit into figured places on the form.
If anyone finds it useful, I will be glad. Errors may occur.
Something like this.

Hello Pardal, I can't unzip the zip and, consequently, I can't run the project....does it work with MVD 5.6?

sparrow wrote:

Hi Derek, Roberto


Some fixes and improvements have been made.
Completely (hopefully) fixed typing in color in Edit.


Hello Sparrow, Show de Bola! Here in Brazil we use the expression "Show de Bola" - which has its origins in our football - to say that it was really good! Congratulations and thank you!

I have attached again the project that allows changing the colors of a form and some of its respective controls at run time. Here are some observations:

➤ I used the script developed by Sparrow. Derek's is very good too;
➤ I used Derek's suggestion to create a button to reset the color settings;
➤ I placed the procedure of the same name in the "OnChange" property of TextBox fields, which is below, to correct the error pointed out by Derek (which is an MVD bug), which does not maintain the text color (foreground) in the field TextBox type, when this is changed. It's the solution I managed to find....using part of the code written by Sparrow.
➤ As soon as the forms are opened, they create a record in the tbl_forms table, which will store the colors defined by the end user;
➤ included the option to increase or decrease the font size of form labels and text in textbox and memo fields

procedure OnChange (Sender: TObject);
//*** to fix MVD bug that does not maintain the foreground color when typing
var
     i: integer;
     tmpFrm: TAForm;
begin
       for i := 0 to Screen.formCount - 1 do
       begin
         if TAForm(Screen.Forms[i]).name = frm_custom.Edit_form_custom.text then tmpFrm := TAForm(Screen.Forms[i]);
       end;
       CompLoad(tmpFrm);
end;

Thank you Derek and K245 for your contributions.

106

(5 replies, posted in Database applications)

sparrow wrote:
jrga wrote:

I'm sorry it doesn't work in MVD 5.6....


Supports versions 5.6 and higher

Thankyou!

107

(5 replies, posted in Database applications)

I'm sorry it doesn't work in MVD 5.6....

sparrow wrote:

Hi Roberto,

Let's simplify the script a little.
Something like this


Hello Sparrow! Congratulations, it turned out great! You used 1/3 the number of lines I used in my script to get the same result. I'm glad we have experts like you on the forum. Thank you very much.

Hello everybody. I use MVD 5.6 and I wanted to create a script that would allow the end user to change the color of the application's forms and some of its controls. It was good, but maybe the code could be simplified. I do not currently have a deeper knowledge of MVD to improve the project. Any help to improve it is always welcome.

sparrow wrote:

Hi Roberto.
It needs to be a little different...
It is necessary that the deletion of the table, its creation and filling be done in the "atualiza_overview" procedure. I'll attach the script.


Hi Sparrow, I used the script.pas you sent in the project, uploaded the file and updated the download link in the original post. Thanks again for helping to improve this project. Everyone wins!

sparrow wrote:

Sorry Roberto)

that's exactly what I meant). "Lost"


One more thing. Table "bar_data".
This table is used once to form a chart and is erased to form a new chart.
At the same time, the size of the database is constantly increasing.
Pay attention to this feature of SQLITE as a temporary table.

    SQLExecute('DROP TABLE IF EXISTS bar_data_temp');
    SQLExecute('CREATE TEMP TABLE bar_data_temp (eixo_x TEXT, eixo_y REAL)');
    SQLExecute('INSERT INTO bar_data_temp (eixo_x, eixo_y) ...  '+

Technically, SQLite stores temporary tables in a separate temp database.
It keeps that database in a separate file on disk, visible only to the current database connection.
The temporary database is deleted automatically as soon as the connection is closed.


Such a table does not need to be registered in MVD.
I offer it just for information. Perhaps it will be useful in future projects, and perhaps in this one too.

Hi Sparrow, I converted the graph table to temporary, as you suggested and re-uploaded the file, whose download link is in the original post. Thanks for the suggestions.

jrga wrote:
sparrow wrote:

Hi Roberto,


good job.


"frmOverview.TableGrid1.beginUpdate" was lost in the atualiza_overview procedure.
Adding the lost one will speed up the output of data to the table.

Hi Sparrow, I'll test it. Thanks.


Hello Sparrow! It worked. That is, it accelerated the consultation. Thanks.


procedure atualiza_overview;
//**** aciona geração da consulta e do gráfico de barras
var
    txt_sel, txt_sel1, txt_where: string;
    c,i: integer;
    total_grid: real = 0;
    Results: TDataSet;
    x_value: string;
    cf_y: string;
    y: integer;
begin
    frmOverview.TableGrid1.beginUpdate; //sparrow
....................
...................
...................
    frmOverview.TableGrid1.EndUpdate; //sparrow
end;

P.S.: Looking at the script I found frmOverview.TableGrid1.beginUpdate "lost" and now I understand your message.

sparrow wrote:

Hi Roberto,


good job.


"frmOverview.TableGrid1.beginUpdate" was lost in the atualiza_overview procedure.
Adding the lost one will speed up the output of data to the table.

Hi Sparrow, I'll test it. Thanks.

tcoton wrote:

@jrga
I see in the video that you are running the compiled project with wine on Mac OS, did you develop this project via wine too or did you use a PC/Virtual machine? I have a Mac too and I use virtual machines for Windows stuffs.

Hello tcoton! I used wine itself via playonMac to develop MVD applications on MAC and also on Linux (playonLinux). Please see the link https://myvisualdatabase.com/forum/view … hp?id=8566

hilal wrote:

anybody can be share sample MVD application with a BI tool ??

5 years ago, I created a solution to analyze data, which is part of the attached project and the one in the link https://youtu.be/gUu7wrpQZKY


Not a B.I. and it is light years away from that, but it allows, through a dynamic query, which makes reference to all the project's interrelated tables, to add values, quantities, check the percentage variation, filter by periods, etc.


Contains a simple graph. I called it "Data Crossing". The objective is the same as those that BI seeks: to assist in decision making.


In this project, which I did for my brother, the data was imported from Access and there were blank related fields and that's why I added the option to filter blank fields, but this is unnecessary when the project is built from scratch. Replaces names, addresses and telephone numbers.


Like so many things in MVD, it can be improved.


link for download:

https://drive.google.com/file/d/1kqnN06 … sp=sharing

sparrow wrote:

Hi Roberto


procedure Form1_OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
  if (Ctrl) and (key=107) then showmessage('You press "+"');   // PLUS on NumPad
  if (Ctrl) and (key=109) then showmessage('You press "-"');   // MINUS on NumPad
end;

Hello Sparrow! Happy 2024! Unfortunately it didn't work! My notebook has a keyboard with a specific layout for the Portuguese language (Brazil) and the '+' symbol is on the same key, above the '=' symbol. Maybe that's why your suggestion didn't work...Thanks anyway! I'll try to capture the decimal code of the key via MVD and, if it's right, I'll post the result here.

PS. Now it worked! Thank you again.:

procedure Form1_OnKeyDown (Sender: string; var Key: Word; Shift, Alt, Ctrl: boolean);
begin
     if ((Ctrl) and (key=107)) or ((Ctrl) and (key=187)) then
          showmessage('You press "+"');
     if ((Ctrl) and (key=109)) or ((Ctrl) and (key=189)) then
          showmessage('You press "-"');  
end;


Hello everybody! I've already used several examples of (Ctrl and/or Shift) + key, posted on the forum, but I didn't find Ctrl plus '+' and Ctrl plus '-'. I tried using the codes above, but without success. If anyone can help, I appreciate it.

derek wrote:

Hi Roberto,
If you want to increase / decrease the font size for all the edit, combobox and memo objects on a form, you could also do it something like this (see attached) which should save a bit of typing!
The attached example  uses ALT + A and ALT +D to increase / decrease the font
I sometimes find it useful to change font size, change object colour etc on forms that have a lot of input fields to make it easier for the user to see where they are (but obviously that is more interactive (ie when you actually enter / leave the input fields))
Regards,
Derek.

Hi Derek! You are always helpful! Thank you for simplifying and at the same time expanding the scope of font enlargement and reduction. I find this very useful in my case, as I have some difficulty with my vision, resulting from surgery, and this feature helps a lot. Happy 2024!

procedure frmNumber_OnKeyDown (Sender: TObject; var Key: Word; Shift, Alt, Ctrl: boolean);
begin //*** Proc 905 - aumenta e diminui o tamanho da fonte com teclas de atalho
     if (Key = ORD('A')) and Shift and Ctrl then
     begin
          frmNumber.ComboBox1.Font.size := frmNumber.ComboBox1.Font.size + 1;
          frmNumber.edNumber.Font.size := frmNumber.edNumber.Font.size + 1;
          frmNumber.Memo1.Font.size := frmNumber.Memo1.Font.size + 1;
     end;
     if (Key = ORD('D')) and Shift and Ctrl then
     begin
          frmNumber.ComboBox1.Font.size := frmNumber.ComboBox1.Font.size - 1;
          frmNumber.edNumber.Font.size := frmNumber.edNumber.Font.size - 1;
          frmNumber.Memo1.Font.size := frmNumber.Memo1.Font.size - 1;
     end;
end;

begin
     //*** ATENÇÃO: keypreview também pode ser acionado em PROPRIEDADES
     frmNumber.KeyPreview := True; //*** Proc 905 - aumenta e diminui o tamanho da fonte com teclas de atalho
end.

120

(2 replies, posted in General)

sparrow wrote:

Something like this.

Thankyou

Sparrow, I made the correction. Thanks!

sparrow wrote:

Hi,
You can try it like this


select PRINTF('AMD: %02d %02d %02d',
                        floor( alldays / 365.25 ),
                        floor( mod(alldays, 365.25) / 30.4375 ),
                        floor( mod( mod(alldays, 365.25), 30.4375) ) )
from (select 
    (julianday('now','localtime') - julianday('2022-10-13')) as alldays  ) as t;    

P.S.
Sorry, I didn't check right away.
For a version of SQLite in a program where some functions are not supported, the query is:

select PRINTF('AMD: %02d %02d %02d',
                         alldays / 365250 ,
                         (alldays % 365250) / 30437 ,
                         ( (alldays % 365250) % 30437)/1000 )
from (select 
    (julianday('now','localtime') - julianday('2022-09-03'))*1000 as alldays  ) as t;

Hi Sparrow, thanks for the suggestion. In fact, your instruction is much less complex than the one I showed you. However, my version of MVD is 5.6 and it does not support the "floor" and "mod" functions. I asked Bing's AI, who suggested replacing these two functions with "Castas...integer" and "%". Below is the instruction with these substitutions. Everything works and thanks again.

(select PRINTF("AMD: %02d %02d %02d",
                        cast((alldays / 365.25) as integer),
                        cast(((alldays % 365.25) / 30.4375) as integer),
                        cast((((alldays % 365.25) % 30.4375)) as integer))
from (select id,
     (case when conclusao is null then julianday('now','localtime') - julianday(inclusao) else 
     julianday('now','localtime') - julianday(conclusao) end) as alldays from tbl_subtasks) where id  =  tbl_subtasks.id)

There may be an easier way to do this, but that’s what I was able to create and it works!


(select PRINTF("AMD: %02d %02d %02d", ano,mes,dia) from (
     select id,        
     case when conclusao is null then round((julianday("now") - julianday(inclusao))/365.25-0.5) else 
     round((julianday("now") - julianday(conclusao))/365.25-0.5) end as ano, 

     case when conclusao is null then round((julianday("now") - julianday(inclusao)- round((julianday("now") 
     - julianday(inclusao))/365.25-0.5)*365.25)/30.41-0.5) else round((julianday("now") - julianday(conclusao)- 
     round((julianday("now") - julianday(conclusao))/365.25-0.5)*365.25)/30.41-0.5) end as mes,  

     case when conclusao is null then round(round((julianday("now") - julianday(inclusao)- 
     round((julianday("now") - julianday(inclusao))/365.25-0.5)*365.25))- round((julianday("now") -  
     julianday(inclusao)- round((julianday("now") - julianday(inclusao))/365.25-0.5)*365.25)/30.41-0.5)*30.41-0.5) else  
     round(round((julianday("now") - julianday(conclusao)- round((julianday("now") -  
     julianday(conclusao))/365.25-0.5)*365.25))- round((julianday("now") - julianday(conclusao)-   
     round((julianday("now") - julianday(conclusao))/365.25-0.5)*365.25)/30.41-0.5)*30.41-0.5) end  as dia

     from tbl_subtasks) where id = tbl_subtasks.id)  

I don't know if I understood the question well. I am using a translator. To not display a specific record in a tablegrid, I place it in the tablegrid definition panel, in "3o. Filter (Not required)": id <> num_id and the same thing in the properties of a combobox in "Filter".

tcoton wrote:

That looks very cool, if only we could design this kind of stuff within My visual Database!!


You can use Qlikview in any MVD application! I decided to share my experience for two reasons: 1 - to contribute to the forum from where I gained all my knowledge about MVD, from where I downloaded countless projects, which further enriched my learning. 2 - encourage users to continue using MVD, in view of that he has been discontinued.