Useful Links Code
Posted
#1
(In Topic #243)
Expert

I created a form with a single scroll view with the background set to Color.White.
It dynamically adds URLLabels with the Tooltip set to display the actual hyperlink and a short description.
This data is contained in a small txt file (Links.Txt) in a format of:
Displayed Name | HyperLink | Short Description.
Clicking on any URLLabel opens the default browser with the address coming from URLLabel.Link.
The order of display is the order in which the lines of the file is read.
<IMG src="https://drive.google.com/drive/folders/1LUuCFHyzb_a4j04Pc-a8Z0k8cnGQWhMb?usp=sharing">
Form Code as below.
Code (gambas)
- ' Gambas class file
- Dim FileName As String = Application.Path &/ "Links.Txt" '\{Change this for the actual location of the file}
- Scv_Links.Children.Clear
- Line Input #LinkFile, TmpLine
- NewLink.Text = TmpAry[0]
- NewLink.Tooltip = TmpAry[1] & Gb.CrLf & TmpAry[2]
- NewLink.Height = 24
- NewLink.Width = Scv_Links.Width - 25
- NewLink.Top = YLocation
- YLocation += Buffer + NewLink.Height
- NewLink.Background = Color.RGB(195, 223, 223)
- SetOdd = False
- NewLink.Background = Color.RGB(255, 255, 223)
- SetOdd = True
- NewLink.Foreground = Color.LinkForeground
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Guru

Unknown identifier: Tmpint in FMain.class:25
Posted
Expert

For those who have already copied the code
just needs to be amended to variable declaration at the top of the sub
I'll do an edit and put it back in
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Guru

Matt and I have looked at your code and made a few changes. Does this help?
Posted
Expert

When did the array.Max turn up or has it always been there ?
Apparently it appears in other controls as well ie: ScrollView1.Children.Max
I assume another little gem from Benoît and that's going to be very useful indeed. !
If {test} Then Continue ?
Now that's a new one on me - Let me think about that one as I need to get my head around how that works
in an IF - Then - Else clause ?
Much cleaner code over all - Nice to lean some new things I must say.
The bit that has me a bit perplexed is :
The 'As ("Link")' code is setting the Name element of the control and it 'should' be unique which is why I added the Str(Number) to it at each creation. Obviously different for created controls.
I'm wondering what would happen if you wanted to do more complex functions with it ?
I'll play with that one and see if there are any exceptions or perhaps the compiler creates a unique token code for each new control ?
Cheers,
A lot of food for thought.
Quin.
Cheers - Quin.
I code therefore I am
I code therefore I am
Posted
Guru

It's been around for some time, it is just the same as .Count -1When did the array.Max turn up or has it always been there ?
Continue jumps to Next, try this: -
The program does not actually need the As "Link" to run but I have added a routine that will show you how you could use it. There is no need add separate links for each URLLabel as you can use Last to find out which item was Clicked, Entered or whatever.The 'As ("Link")' code is setting the Name element ….
Posted
Regular

.... and carry a big stick!
1 guest and 0 members have just viewed this.

