401

(1 replies, posted in Script)

Hello Dmitry and all MVD fans,

Here is what I am trying to do :

1- Get the code of a web page with HTTPGet (Works fine)
2- Get position of a tag in that code with Pos (Works fine)
3- Delete code from 1st position to position of the tag (does not work).

The error I get is as follows :

http://i.imgur.com/CQc0fWX.jpg

What I don't understand is that StartPos given my POS(someting) is an Integer, and that DELETE(String, Integer, Integer) should recognize StartPos as an Integer.

I'm a bit lost smile

Any idea ?

procedure Form2_Button1_OnClick (Sender: string; var Cancel: boolean);
var
    URL : String;
    Source : String;
    Longueur : String;
    StartPos : Integer;
    Source2 : String;
begin
    URL := Form2.Edit1.Text;
    Source := HTTPGet(URL);
    Longueur := IntToStr(Length(Source));
    Form2.Edit2.Text := Longueur;
    StartPos := Pos('<span class="sku_number">',Source);
    //Form2.Edit3.Text := IntToStr(StartPos);
    Source2 := Delete(Source, 1, StartPos);
    Form2.Edit4.Text := Source2;

end;

Thank you in advance and a good day to you all

Cheers

Mathias

402

(7 replies, posted in General)

Hello Dmitry and Thank you so much for your reactivity !!

I downloaded the new beta and tried it with a few URL, it looks to work fine.

I'll do some more extensive tested latter on today and come back to you.

As always you've been fast and efficient, thank you again.

Sincerely

Math

403

(7 replies, posted in General)

Thank you Dmitry for this addition to your next release.

I had time to test with a very small program : a Textbox where the user fills the URL and a button to launch HTTPGet.

It works fine with adresses like yours : http://myvisualdatabase.com/

But if you try something else like : http://docs.daz3d.com/doku.php/public/r … 8695/start

here is what you get :

http://i.imgur.com/vW4MA60.jpg

I checked the packets and the main difference between the acess on the same adresse with Firefox and MVD is this :

Date: Tue, 10 Nov 2015 02:19:48 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: __cfduid=d14c57bebef44f07a5f47839e85244dd21447121988; expires=Wed, 09-Nov-16 02:19:48 GMT; path=/; domain=.daz3d.com; HttpOnly
Cache-Control: max-age=10
Expires: Tue, 10 Nov 2015 02:19:58 GMT
X-Frame-Options: SAMEORIGIN
Server: cloudflare-nginx
CF-RAY: 242e464b54a419ce-SYD

cd9
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Access denied | docs.daz3d.com used CloudFlare to restrict access</title>

I think the problem is here :
Set-Cookie: __cfduid=d14c57bebef44f07a5f47839e85244dd21447121988; expires=Wed, 09-Nov-16 02:19:48 GMT; path=/;

I think MVD does not handle cookies and Cloudflare somehow restrict the access.
Also, MVD impersonate itself as Mozilla/3.0, might also be a problem ?

User-Agent: Mozilla/3.0 (compatible; Indy Library)

Thank you for your patience and any help you could give.

Cheers

Math

404

(7 replies, posted in General)

Hello Dmitry and all MVD fans,

The million dollars question...

Is it possible, at the moment (or in the future) to parse a web page ?

For example, I enter the URL of a page, and save into the database, info from the page based on the tags contained on the page's code ?

Ooooh God, I hope the answer is yes smile

Cheers

Math

405

(2 replies, posted in Script)

Hello Dmitry,

Thank you for your answer !! That does exactly the trick !!

Thanks again

Math

406

(2 replies, posted in Script)

Hello Dmitry and all MVD fans,


Thanks to the forum and the onlinehelp, I was able to open and read any kind of files (txt, and others as well).


I also found a way to select a specific line in a file.


What I did not find is how to break that line into pieces according to it's structure.


I mainly focused on the SplitString and Trim functions (String Routines), but did not quite get what I was expecting.


Any idea for me ?

Examples :


How could I extract  Some product name from the line  <ProductName VALUE="Some product name"/> ?


Or, how could I extract the x first characters in a string like :
fb63882b-4498-4215-bfa0-b2eef88eb3f7 = Default Lights and Shaders


Or, from character x to character y ?


Thanks in advance and have a good day

Cheers

Math

407

(4 replies, posted in Script)

Thank you Dmitry for your answer.

I found a way around that problem, but I might come back to it later smile smile smile smile

408

(4 replies, posted in Script)

Hello Dmitry,

Thank you for your fast answer as usual !
On second thought, saving multiple values in one single field is a bad idea. I'll try something else and keep you posted (I plan on a pairing table with only id in it).

But I still have another related question :

I'm trying to save records as I go from form to form (because I need the id of the newly created product for pairing it with keywords).

So the product is created and saved in FormA (no problem here), and when FormA is closed, FormB is opened.
In order to assign keywords to this product, I need to lookup it's id in the table "products".

Her'es my code :

Var
prod_id : String;

procedure new_product_Button1_OnClick (Sender: string; var Cancel: boolean);
begin

    new_product.hide;
    new_product_keywords.Show;
end;


procedure new_product_keywords_OnShow (Sender: string; Action: string);


begin
    prod_id := IntToStr(Last_Insert_id('products'));
    new_product_keywords.Label_prod_id.Caption := prod_id;
    new_product_keywords.Edit_prod_id.Text := prod_id;
end;



begin

end.

I have no error message, but the result (displayed in an Edit Field and in a label) is always 0.
What do you think am I doing wrong ?


Cheers

Mathias

409

(4 replies, posted in Script)

Hello all MVD users, it's been a long time ! A lot of changes in my life for the past few months have kept me away from keyboard and coding :-)
Hope you all go well !

I'm sure my question as already been posted, but I couldn't find any reference to it...

I would like to assign keywords to a product I store in a database.
The simple solution would be to create for example 5 keywords fields in the product database, assigning them in order.
But what if I want more ?

My question is : instead of creating a fixed number of field for keywords, how would you concatenate x keywords in just one field ? And of course, how would you read them from database and display them in a form ?

Happy to be back with you all.

Cheers

Math

410

(7 replies, posted in General)

Well... I don't get it... I missed your post to Dmitry...


I don't understand why it works after upgrading for you while it does not for me with the same version ? Furthermore, why would 2 out of 3 tablegrids work and one not if this is a version bug ? Shouldn't the 3 tablegrids be broken as well ?


Anyway, glad you solved your problem smile


Math

411

(7 replies, posted in General)

Hello Dmitry and Derek,


@Derek : If by messy you mean complex and interesting idea, then yes your project is messy smile


@Derek and Dmitry : I am using latest version of the v1.50 (the one with version 4 in the .vdb file). Why would the first and third tablegrids work and not the second one if it's a version bug ?


The lack of calculation is still there, it only take into account the last line displayed in the tablegrid :


http://i.imgur.com/DTxl4Jw.png


@Derek and Dmitry : just change that line of code I showed you and it should work


http://i.imgur.com/bhfX9Yw.png

412

(7 replies, posted in General)

OK, I think I found your bug smile


The problem was not with the blank line (no value or 0), but with the 'sfa' variable that was assigned to footer too early in your code, before the calculation. Only the last line was taken into account.


Try changing the line in red, it is misplaced - move it to the line in green, should work.


http://i.imgur.com/fUjBDVl.jpg


Math

413

(3 replies, posted in General)

I see you declare the variable before the procedure, and not between procedure and begin.


I suppose this means that the variable i will be reusable for other procedure after it as been declared but what about the result ?


Can I do something like :


var
DateTimeTot1 : TDateTime;
DateTimeTot2 : TDateTime;
diff, day, hour, minute : Integer;

DateTimeTot1 := Trunc(Form1.date_begin.DateTime) +  Frac(Form1.time_begin.DateTime);
DateTimeTot2 := Trunc(Form1.date_end.DateTime) +  Frac(Form1.time_end.DateTime);
diff:=  SecondsBetween(DateTimeTot1,DateTimeTot2);

Procedure
begin ...

I mean not only declaring variables but assigning values as well; that will be reused for different calculation in different procedures after that ?


Mathias

414

(3 replies, posted in General)

Hello Dmitry and all MVDB users;


THIS QUESTION IS NOT URGENT, it's just my curiosity and maybe a little convenience of use that make me ask smile


In php, as long as a session is active, there is an easy way to keep already used variables and there values for reusing them.


I noticed that, as soon a an "end;" as been set for a procedure, the variables used in these procedure are lost and must be re-declared and re-calculated for use in the next procedure if needed.


Is there a way to keep those variables active and re-usable all along the code ? (global variables maybe ?)


Again, this is not an urgent question.


I wish you all a good day


Cheers


Mathias

415

(7 replies, posted in Script)

Hello Jean (and Dmitry),


Here is the final WE app for testing. There is no other use for this tool than implementing what Dmitry gave me for counting working days, and also a demonstration on how to dynamically change the title bar of the window based on a calendar click.

As stated by Dmitry, this is developped under the last version of V1.50

Have a good day all

Cheers


Mathias

PS : and again many thanks to Dmitry

416

(7 replies, posted in Script)

Dmitry you're the best !


I was trying something like :

  • count days

  • find what the first day is

  • divide total number of days by 7

  • chain the if conditions with divisions and modulos to find how many saturdays and sundays

This looks like pure magic to me and in the same time it is so logical now that it is written !


Thanks again

Mathias

417

(7 replies, posted in Script)

Hello Dmitry,


Again, I'm asking for help smile


After successfully (thanks to you) calculating a total number of days, hours, minutes between 2 dates, I am trying to calculate to total number of working days between the same dates.


In other word, I am trying to count the DaysBewteen minus Saturdays and Sundays.


I used the DayOf Week (week starts with a Sunday) because it seems that the DayOfTheWeek (week starts with a Monday) is not yet implemented (which does not matter at all in fact).


I suppose what must be done is calculate the total number of days between the dates, and substract all the [1] and [7] days (Sundays and Saturdays) with some kind of loop... but how ?


Do you have a idee for me ? Or anyone else maybe ?


In the included project, days of beginning and ending dates are identified, and DaysBetween are also calculated but I don't have a clue on how to substract Saturdays and Sundays sad


MVDB version is 1.50

418

(3 replies, posted in Script)

Hello Dimtry and thank you for your help, question is solved.


I post my project as an example if someone needs it or if you want to keep it for further reference


I used 2 different approaches for calculating the result :


1- conversion in seconds and then divisions and modulos for each steps

2- direct conversion in days/hours/minutes wit the between method  and modulos


Each method gives the same result (script is commented in english).


Thanks again for you valuable help.


Cheers


Mathias

PS1 : version of MVDB is 1.50
PS2 : no guaranty that it's 100% bug free smile

http://i.imgur.com/uxsAZ6m.jpg

419

(3 replies, posted in Script)

Hello Dimtry,


I've searched the forum and found some partial answers to my upcoming question, but I was unable to completely solve my problem.


I would like to make calculations on dates.


Getting the elapsed time bewteen two dates is easy with

SecondsBetween
MinutesBetween
HoursBetween
DaysBetween

and so on


But that is when you only have a date picker.


FIRST QUESTION : can I have a datepicker with date AND time ?
I tried something like 'yyyy-mm-dd hh:mm' in the datepicker format and it works but...  here comes the second question


SECOND QUESTION : how do you make calculation on those datepickers with date AND time ?
I've tried

SecondsBetween(Form1.beginhour.DateTime,Form1.endhour.DateTime)

with beginhour 2015-03-13 10:30 and endhour 2015-03-13 11:30 and the result should be 3600


But it returns 0.


Did I miss something ? Is the format wrong ? Or is it just impossible at the moment maybe ?


Thanks in advance


Cheers


Math


PS : this is not to calculate the age of a person smile

420

(4 replies, posted in General)

Thank you Dimtry for your quick answer.

Well, I'll open link in browser then, not a problem :-)

421

(4 replies, posted in General)

Oups, not directly linked to the question, but I jump on the occasion, sorry :-)

Did I understand right ? Is it possible to call (display) webpages directly in MVDB ?

If this is so, I'd love to see an example of how you do that.

Thanks

Math

422

(12 replies, posted in Script)

By two variables do you mean for example :


if 0 then color is green
if between 1 and 5 color is orange
if 6 or greater then color is red ?


Is it the between statment that causes you problem ?


If yes (and I say if because it would not be the first time I answer a question you did not ask wink), then you shoud try the in [x..y] statment like this :

if Form1.TableGrid1.Cells[1,i] in [0..9]) then
...instruction...
if Form1.TableGrid1.Cells[1,i] in [10..19]) then
...instruction...
if Form1.TableGrid1.Cells[1,i]  >=20 then
...instruction...

Hope I got it right this time wink


Have a good day


Mathias

423

(12 replies, posted in Script)

OK, understood smile

Question : do you have a table with multiples rows and the tablegrids adds together the 3 status to give you total count of each, or do you have only 3 rows in that table with a total number for each ?

In other words, is the value displayed in the tablegrid calculated before beeing displayed ?

424

(2 replies, posted in Script)

Aaaaaaah, clever : include on the form closed by the user, a procedure to close the intial form !!

That did the trick, thank you smile

425

(12 replies, posted in Script)

Maybe the InRange Function is what you are looking for

http://delphi.about.com/library/rtl/blr … ndling.htm