Here's a sample application of the counter. You need to have a counter component in the form and include it in saving the data

202

(5 replies, posted in Script)

Rein wrote:

Haw can i delete an script?

Is it the script you want to delete ? If so, what kind of delete? Or you want to delete a record using script?

203

(11 replies, posted in General)

Happy to know you guys are well. Looking forward to your releases.

204

(16 replies, posted in Talks about all)

I hope dmtry continue and release some updates. Been using MVD for years and it helps me a lot in developing our applications faster.

205

(9 replies, posted in General)

It's because you didn't populate col1 in the previous record

206

(9 replies, posted in General)

AD1408 wrote:
brian.zaballa wrote:

Been busy, sorry.
You can get it using query in script. Something like

Form2_OnShow (Sender: TObject; Action: string);
begin
    if Action = 'NewRecord' then
        Form2.EditField.Text := SQLQuery('SELECT `col5` FROM `Chain` ORDER BY `id` DESC LIMIT 1');
end;

Hi Brian,


Thanks a lot for the script, but I get "not enough actual parameters" script error.

My Bad, LMAO, change SQLQuery to SQLExecute

207

(9 replies, posted in General)

Been busy, sorry.
You can get it using query in script. Something like

Form2_OnShow (Sender: TObject; Action: string);
begin
    if Action = 'NewRecord' then
        Form2.EditField.Text := SQLQuery('SELECT `col5` FROM `Chain` ORDER BY `id` DESC LIMIT 1');
end;

208

(9 replies, posted in General)

can you provide a sample records/result? 5 records i think would be nice.

209

(5 replies, posted in Script)

Good Day.
Here's a sample.

210

(7 replies, posted in Script)

kofa wrote:

very good brian.zaballa

is it possible to change input direction to right to left and input position

In other words, how can i make the word (Title ) to the right and the input to the left

thanks for help

I think it cannot be done for that inputbox is a delphi/pascal's function to begin with. If you really want, you can create your own dialog using form and components.

211

(7 replies, posted in Script)

kofa wrote:

i used this code

var t : String;
begin
    t := inputbox('Hello', 'Title', 'default');
    if t ='123' then showmessage(correct)
    else if t <>'123' then showmessage('wrong');
end;

but when i press No or    X (close)  showmessage('wrong') appeared too

can you help me

maybe this will fix it

var
    d : String = 'Default Value';
    t : String;
begin
    t := inputbox('Hello', 'Title', d);
    if ((t ='123')) then showmessage('correct')
    else if ((t <>'123') and (t <>d)) then showmessage('wrong')
end;

but this will not also show any message when default value is entered

212

(7 replies, posted in Script)

kofa wrote:

hello all

how can i make a MessageBox  with input txt and YesNo buttons

Yes ===>  if input txt = '123'  then any code here

No  ===> Return


thanks for help

try this.

var t : String;
begin
    t := inputbox('Hello', 'Title', 'default');
    showmessage(t);
end;

213

(16 replies, posted in General)

brian.zaballa wrote:

how about this?

frxReport1.PrepareReport;
frxReport1.Print;

Tested this, no luck.

214

(16 replies, posted in General)

how about this?

frxReport1.PrepareReport;
frxReport1.Print;

215

(16 replies, posted in General)

blackpearl8534 wrote:

I am generating report using script.. how can i get quick print and avoid preview..
I am scripting like this

form1.frxreport.print;

But not works...

Try PrintReport instead of print (just guessing)

216

(2 replies, posted in General)

I'm not sure if this is what you are looking for but I hope it gives you an idea.

Here's a close solution to the problem.

var Names : array[0..10] of string;
    i,j,longest:Integer;

procedure Form1_OnShow_Event (Sender: TObject; Action: string ;DataSet: TDataSet); begin
     Names:=['all','john','alisa','makhmara','kiven','brad toki','salamoiya','lomia gone','steven baloka','irak fone','qutazami phoronix'];

     // get length of longest string
     longest := Length(Names[0]);
     for i:=1 to Length(Names)-1 do
        if Length(Names[i]) > longest then longest := Length(Names[i]);

     Form1.ComboBox2.Items.Add(Names[0]+'             ');  // 13 space
     Form1.ComboBox2.Items.Add(Names[1]+'          ');   // 12 space
     Form1.ComboBox2.Items.Add(Names[2]+'            ');   // 12 space  
     Form1.ComboBox2.Items.Add(Names[3]+'        ');       // 8 space
     Form1.ComboBox2.Items.Add(Names[4]+'            ');    //12 space
     Form1.ComboBox2.Items.Add(Names[5]+'          ');     // 10 space
     Form1.ComboBox2.Items.Add(Names[6]+'         ');      // 9 space
     Form1.ComboBox2.Items.Add(Names[7]+'         ');       //9 space
     Form1.ComboBox2.Items.Add(Names[8]+'        ');       // 8 space
     Form1.ComboBox2.Items.Add(Names[9]+'           ');     //11 space
     Form1.ComboBox2.Items.Add(Names[10]+'     ');         // 5 space
     Form1.ComboBox2.ItemIndex:=0 ;

     for i := 0 to Length(Names) -1 do begin
           // Names[i]:= ;     // how to calculate a number of spaces for each element
           if  Length(Names[i]) = longest then
               Form1.ComboBox1.Items.Add(AddSpaces(Names[i], longest-Length(Names[i])+1))
           else if (Length(Names[i]) mod 2) = 1 then
               Form1.ComboBox1.Items.Add(AddSpaces(Names[i], longest-Length(Names[i])))
           else
              Form1.ComboBox1.Items.Add(AddSpaces(Names[i], longest-Length(Names[i])-1));

     end;
     Form1.ComboBox1.ItemIndex:=0 ;
end;

function AddSpaces(str: String; count:Integer=5):String ;
var
    i: Integer;
begin
    result := str;
    for i:=0 to count do result := result +' ';
end;

{
//https://stackoverflow.com/questions/15294501/how-to-count-number-of-occurrences-of-a-certain-char-in-string
}
function OccurrencesOfChar(const S: string; const C: char=' '): integer;
var
  i: Integer;
begin
  result := 0;
  for i := 1 to Length(S) do
    if S[i] = C then
      inc(result);
end;


begin
end.

something like this? Sorry, I'm not so sure on where you are going to use the count of spaces so I just put it in the combobox to showcase

219

(7 replies, posted in General)

AD1408 wrote:

Hi Brian,

I'm getting an error message:
"table settings has 97 columns but 3 values were supplied"
I have 96 fields in Settings db table


when trying to apply the following script - Using your script:

procedure Form1_OnShow (Sender: TObject; Action: string);
var
SData : TDataSet;

begin
SQLQuery('SELECT * FROM settings LIMIT 501', SData);
if Not SData.EoF then begin
       Form1.mainPanel501.Top := SData.FieldByName('mainPanel501Top').asInteger;
       Form1.mainPanel501.Left := SData.FieldByName('mainPanel501Left').asInteger;
   end else SQLExecute('INSERT INTO `settings` VALUES (501,501,501)');

SQLQuery('SELECT * FROM settings LIMIT 502', SData);
if Not SData.EoF then begin
       Form1.mainPanel502.Top := SData.FieldByName('mainPanel502Top').asInteger;
       Form1.mainPanel502.Left := SData.FieldByName('mainPanel502Left').asInteger;
   end else SQLExecute('INSERT INTO `settings` VALUES (502,502,502)');

SQLQuery('SELECT * FROM settings LIMIT 503', SData);
if Not SData.EoF then begin
       Form1.mainPanel503.Top := SData.FieldByName('mainPanel503Top').asInteger;
       Form1.mainPanel503.Left := SData.FieldByName('mainPanel503Left').asInteger;
   end else SQLExecute('INSERT INTO `settings` VALUES (503,503,503)');
end;

That sql query is only applicable to settings table that I've created in the sample which only have 3 fields including id just to give you an idea.

that settings table I created is only intended for 1 record only to handle system settings and that insert query is only applicable if the table only have 3 fields. Safe way to represent it in your case is something like this

SQLQuery('SELECT * FROM settings LIMIT 1', SData);
if Not SData.EoF then begin
    Form1.mainPanel501.Top := SData.FieldByName('mainPanel501Top').asInteger;
    Form1.mainPanel501.Left := SData.FieldByName('mainPanel501Left').asInteger;

    Form1.mainPanel502.Top := SData.FieldByName('mainPanel502Top').asInteger;
    Form1.mainPanel502.Left := SData.FieldByName('mainPanel502Left').asInteger;

    Form1.mainPanel503.Top := SData.FieldByName('mainPanel503Top').asInteger;
    Form1.mainPanel503.Left := SData.FieldByName('mainPanel503Left').asInteger;
end else SQLExecute('INSERT INTO `settings` (id) VALUES (1)');

Note: Make sure you set all fields in your settings table to not null and have a default value 0 or 1, or 2, your choice to prevent an unexpected error.

220

(7 replies, posted in General)

AD1408 wrote:

Hi sibprogsistem,


Great stuff.... Thank you very much... Truly appreciated.


How could we restrain move into form edges.. In other word user cannot move panels outside the edges of the form?
Plus how can I save moved panels position so that next time application run shows last set position?


Once again thanks for your kind help......

One way I can think of is to save its top and left in database.

Here, I made some modification in sample21 with regards to your question.

v_pozidis wrote:

does anyone know how to change from the properties the details of the created exe file from the MVDB. I am using win10 64 bit

https://ibb.co/rZvkTnN

Try using Resource Hacker, then open your exe. then attached is the picture of the process

222

(5 replies, posted in General)

kweatherhead wrote:
brian.zaballa wrote:
kweatherhead wrote:

I would like to add, from the pages of the gurus... if these libraries are capable to be done, do you suffer loading the entire library or only the code you need (more of a Link time functionality?  Is there a way to manage pieces within a library, etc....

Regards,
Keith

You can only use the "Uses" and include .pas file which is a raw code of your libraries.


Brian,

Again a great example  !!   I presume that you must distribute your Libs with your app if deploying on another system, correct?
MVD does not make a lib.dcu  correct?

Keith

Yes., So try not to include critical scripts in there. smile

223

(2 replies, posted in Script)

Good day keith,

Here's a sample to give you an idea on the keydown event

224

(5 replies, posted in General)

kweatherhead wrote:

I would like to add, from the pages of the gurus... if these libraries are capable to be done, do you suffer loading the entire library or only the code you need (more of a Link time functionality?  Is there a way to manage pieces within a library, etc....

Regards,
Keith

You can only use the "Uses" and include .pas file which is a raw code of your libraries.

225

(26 replies, posted in Script)

kofa wrote:

hello all

i want to make message box with ok and cancel

i tired to solve this code

procedure Form1_Button6_OnClick(Sender: TObject);
var
  buttonSelected : Integer;
begin

  buttonSelected := messagedlg('Confirmation',mtError,mbOKCancel, 0);
  if buttonSelected = mrOK     then ShowMessage('OK pressed');
  if buttonSelected = mrCancel then ShowMessage('Cancel pressed');
end;

can you help me

thanks for help

you can try this custom function

//Comfirm massages with "Yes or No"
function Confirm(msg: String; ICON: Integer=MB_ICONQUESTION; title:String='Confirm'): boolean;
begin
    result := IDYES = MessageBox(msg, 'App Name: '+title, MB_YESNO+ICON);
end;

to use it,

if Confirm('Are you sure?') then begin
    showmessage('ok');
end else begin
   showmessage('cancel');
end;