I am trying to pass a function reference to another function. Any thoughts on how to achieve this ?

function add(a, b : integer) : integer;
begin
    Result := a + b;
end;

function sub(a, b : integer) : integer;
begin
    Result := a - b;
end;

function mul(a, b : integer) : integer;
begin
    Result := a * b;
end;

function action(a, b : integer; f : function) : integer;
begin
    Result := f(a,b);
end;

http://interactiveasp.net/blogs/spgilmo … -2010.aspx

2

(2 replies, posted in Script)

I am using below code to get the selected Items It works fine in case of single select combo box and also for individual selections in multiselect combobox. But not working fine with using Select All option in the multi select Combo Box. Any suggestions ?

function getComboBoxSelections(cb : TdbComboBox) : Variant;
var
  i, counter : integer = 0;
  arr : array of string;
begin
  SetLength(arr, cb.SelectedCount);
  if cb.SelectedCount > 0 then
  begin
    for i := 0 to cb.Items.Count-1 do
    begin
        if cb.ItemsChecked[i] then
        begin
          arr[counter] := cb.Items[i];
          Inc(counter);
        end;
    end;
  end;
  result := arr;
end;

procedure frmMain_OnShow (Sender: TObject; Action: string);
begin
           frmMain.ComboBox1.MultiSelect := True;
           frmMain.ComboBox1.Items.Add('All');
           frmMain.ComboBox1.Items.Add('a');
           frmMain.ComboBox1.Items.Add('b');
end;

procedure frmMain_ComboBox1_OnChange (Sender: TObject);
var
v:variant;
begin
          v := getComboBoxSelections(frmMain.ComboBox1);
end;

3

(2 replies, posted in Script)

Oh... Its good to know, I thought all pascal things are supported by referring below link

Introdunction to script - http://myvisualdatabase.com/forum/viewtopic.php?id=2277

Thank you vovka3003.

4

(2 replies, posted in Script)

I am new to pascal but i am trying to learn from online resources. I am trying to use custom types.

But they are showing error in MVD. Guide me on this.

type
   TDay = (Mon=1, Tue, Wed, Thu, Fri, Sat, Sun);   // Enumeration values

type
  atom = record
      electrons: integer;
      neutrons: integer;
      protons: integer;
  end; 

 var
   today   : TDay;
   x : atom;

References:

Enumeration - http://www.delphibasics.co.uk/Article.asp?Name=Sets

Record - http://www.delphibasics.co.uk/Article.asp?Name=Records

5

(0 replies, posted in Script)

I am trying to use json in script, for that  i am using the fpjson unit provided with fpc.

https://www.freepascal.org/docs-html/cu … index.html

But don't know how to link or use in MVD. Please advice me on this.


uses fpjson, jsonparser;

Var
  D,E : TJSONData;

begin
  D:=GetJSON('{ "Children" : ['+
             '  { "Age" : 23, '+
             '    "Names" : { "LastName" : "Rodriquez",'+
             '                "FirstName" : "Roberto" }},'+
             '  { "Age" : 20,'+
             '    "Names" : { "LastName" : "Rodriquez",'+
             '                "FirstName" : "Maria" }}'+
             '  ]}');
  E:=D.FindPath('Children[1].Names.FirstName');
  ShowMessage(E.AsJSON);
  D.Free;
end.

6

(4 replies, posted in Script)

As an alternative i found the 'visual studio code' extension 'Pascal' to edit the script with multiple script files. Its auto-suggestion and error highlighting features are cool.

Pascal Editor Extension : https://marketplace.visualstudio.com/it … ani.pascal

7

(4 replies, posted in Script)

brian.zaballa wrote:

You can only edit the script in there, but you can not compile it there

I am not trying to compile there. I am trying to use that as an editor with auto-suggestions for multiple pas file scenario.

Because of the error  Identifier not found "TdbComboBox" '. I am not getting property/method suggestions for TdbComboBox.

8

(3 replies, posted in Script)

Thank you brian.zaballa.

It worked. :-)


While searching about this, I came across the 'Unit' Concept.

https://wiki.freepascal.org/Unit

Unit approach is not working. Is it supported ?

9

(4 replies, posted in Script)

I am trying to use external 'Charm Pascal' IDE for editing the script.

In that I got the 'Error : Identifier not found "TdbComboBox" '

How to resolve this ?

10

(3 replies, posted in Script)

I am trying to have script separated by forms and separate script to maintain common functions/procedures.

But its showing error. Have all the 3 files in 'Script' folder of the project. Please advice me on this.

---------------
file - script.pas
----------------
uses 'form1.pas', 'common.pas';
//uses 'common.pas';

var
  sHello: string;

begin
  // just for example
  sHello := 'Script said hello!';
  HelloWorld(sHello);
end.     

----------------
file - common.pas
----------------
procedure HelloWorld (s: string);
begin
  ShowMessage(s);
end;

---------------
file - form1.pas
----------------
uses 'common.pas';

procedure cb_Button1_OnClick (Sender: TObject; var Cancel: boolean);
var
begin
     HelloWord('Hello from form1');
end;

11

(10 replies, posted in SQL queries)

Thanks a lot brian.zaballa. I understand the solution.

Thank you all.

12

(10 replies, posted in SQL queries)

First of all my Thanks to derek, thezimguy, sibprogsistem, brian.zaballa, ehwagner for you suggestions.

@brian.zaballa - Updating the latest sqlite3.dll in the MVD installtion directory worked like a charm. Now, its allowing me to use all the latest sqllite in-built fucntions. Initially I replaced sqlite3.dll in the project folder and tried. That's why it was not working.

@ehwagner - I was trying to use the ROWNUM() function as an id attribute for dropdown. Your approach by having a intermediate table is also good.  In the project you have attached why the drop down field is showing blank after choosing an item ? How to hold the selection ?

13

(187 replies, posted in General)

MVD is awesome. Its growing stable with new features.

Its good to have below features.

1) New field called sql in the combo box object inspector which accept such as 'select name from person where cond'
2) For the combo box the refering table don't have id then id to be used as 1,2,3.. Right now it's saying can't find id column
3) Support to SQLite functions like ROW_NUMBER() OVER (ORDER BY name) (https://www.sqlite.org/windowfunctions. … _functions) in script
4) Allow to have custom names for relationships to have the names as meaningful.
5) For combobox introduce a property called value -> text / id. For example, if we have a separate table for gender and person table. Then it makes sense like storing the gender text (M/F) in person table.
6) radio button
7) date time picker
8) improved navigation in script editor.
9) listbox

14

(2 replies, posted in General)

MVD Team,

Any plan to incorporate this in future releases ?

15

(10 replies, posted in SQL queries)

Derek, in your example you haven't added the rownum function.

SELECT ROW_NUMBER() OVER (ORDER BY name) as id,  name FROM sqlite_master WHERE type="table"

I also tried with below query to get the list of fields in a table. But that too not working in MVD.

SQLQuery('select name from pragma_table_info("sqlite_master")', dataSet);

I think MVD is not allowing paranthesis in the sql query.

Is there any other way to get this Working ? I badly need this :-(

16

(10 replies, posted in SQL queries)

I tried with 32-bit DLL (x86) for SQLite version 3.33.0 from sqlite download page.

But no luck. Still the same error.

Using the below query I am trying to populate the data in dropdown which list the list of tables in sqllite db.

SELECT ROW_NUMBER() OVER (ORDER BY name) as id,  name FROM sqlite_master WHERE type="table"

But this is working if run i sqlite manager. But in MVD its show as syntax error.

How to get this query running in MVD ?

18

(1 replies, posted in General)

I am having 2 tables as follows

Table - Fields - Sample Values
------------------------------------------
Pesron - name, phone_type, number - William, Mobile, 1234
Phone_Type - type - 1) Mobile 2) Homephone

Phone type is a combo box in the form. But i want to save the phone type value in person table not its id.
For example, I want to save the Phone type value 'Mobile' to be saved in Person table rather than its id '1'.

I know this can be achieved using coding. Is there any way to achieve this without coding ?

If not possible, I am looking forward to this feature in future versions of MVD.

19

(2 replies, posted in General)

For long time (more than a year) i was searching for a good sqlite based RAD tool for my personal use. Finally come to know about this MVD and i am feeling very happy about it. Kudos to the MVD team for this wonderful tool !!!

I am a software engineer and I have explored its feature they are great and awesome.

I don't know whether below things can be achieved without coding. If not then i am expecting them in the future versions of MVD.

Currently, when i am creating two relationships on same field the field names are being chosen automatically.
For example, Each person (person table) has two address (address table) namely home, office.
Their foreign key names will be 'id_address'  for home and 'id_address1' for office.
Ideally the field names should be 'home' and 'office'
I feel these name are not meaningful and hard to remember when the foreign key count increases.

So, is there any way to provide a custom/user-defined name for foreign keys without affecting the combo box references ?
Because it will help me to keep the database field name meaningful and also the copy of sqlite can be used as a backend for my web application.