Topic: Link

How do I link a label text or button to a file within project folder?


For instance:
- If I put an image into folder within project folder, on click it opens the image on users default image browser
- If I put a .txt file into folder within project folder, on click it opens the text file on users notepad
- If I put a excel file into folder within project folder, on click it opens the file on users excel app if they have it
and so on...

Adam
God... please help me become the person my dog thinks I am.

Re: Link

Hi  AD1408,
Quite a few ways but I find the easiest (and therefore always the best for me!!) is, in your script,  'openfile' + location + filename. 
For example -
procedure Form1_Label1_OnClick (Sender: string);
begin
  openfile('C:\Documents and Settings\user\Desktop\M.V.D\ad1408filelink\images\DSC01781.jpg');
end;
Depending on the file extension, it will open whatever type of file it is with your default program.
If you want it to link to the folder so the user can then pick a file, then write
procedure Form1_Label1_OnClick (Sender: string);
begin
  openfile('C:\Documents and Settings\user\Desktop\M.V.D\ad1408filelink\images\');
end;
Derek.

3 (edited by AD1408 2016-09-07 13:36:28)

Re: Link

Hi Derek,


Many thanks for quick reply.


Done the c/p of the code you supplied but couldn't make it work. Please see the sample project attached.


Ps/. I only have hide menu code on my project Script tab as below. Please put linking code with hide menu one altogether so that all works

begin
     Form1.mniFile.Visible := False;
     Form1.mniOptions.Visible := False;
     Form1.mniAbout.Visible := False;
end.

begin
end.
Post's attachments

Attachment icon File linking.zip 332.79 kb, 386 downloads since 2016-09-07 

Adam
God... please help me become the person my dog thinks I am.

Re: Link

Hello AD1408,
I don't believe it is a version issue (I am using 2.5 but went all the way back to 2.1 just to be on the safe side and it still works okay for me).
The copy and paste you've done is fine so the only thing I can think of is that the directory and/or file name that you entered (zztemp\test.txt) does not exist at your end, in which case when you click it will simply do nothing.
Derek.

Post's attachments

Attachment icon File linking.zip 335.3 kb, 385 downloads since 2016-09-07 

Re: Link

Thanks a million Derek..... You're a life saver.


Yep, one z was missing on folder name.. it's all good now.


Also thanks for putting the code together and uploading. It helps me further my understanding.

Adam
God... please help me become the person my dog thinks I am.

Re: Link

Hello AD1408

About your post Today 14H32

Be careful.

In Pascal language, the pair  Begin ... End. (with a dot) means the end of the script.

All that appears after will not be executed, so you can delete those two keywords (in Pascal) Begin End with nothing between.

To complete the good informations given by Derek, you can also offer to the end user to choose a file in a folder via function OpenDialog.

JB

Re: Link

Hi JB,


Thanks for the info...


Yes, I'm grateful to Derek for his kind help on many occasions.


I have attached sample work project which Derek done hard linking settings and script. We'd also need relative linking. Need to link for files put in MVD compiled project folders relative links as end user may put app folder in a different location on his computer. Can you do this JB or anybody else?


JB, if you also could add "...file in a folder via function OpenDialog" to project would be nice.

Post's attachments

Attachment icon File linking 2.zip 3.41 kb, 379 downloads since 2016-09-07 

Adam
God... please help me become the person my dog thinks I am.