PDA

View Full Version : Hard coded inks


bobbie
02-08-2006, 09:49 PM
I have the top of the window with little images that are hard coded with weblinks. How hard would it be to use say txt file etc that would hold the links so they could be changed if wanted?

Corey
02-08-2006, 10:18 PM
Not hard at all. Just use variables for your link(s) code and then use a TextFile.ReadToTable action to retrieve the link values from your text file on startup and place them into the appropriate variables. Here's a one button example attached, but you can add as many urls to the text file as you like, just refer to them according to their position in the table, i.e. myURL[1], myURL[2], etc. :yes

bobbie
02-08-2006, 10:25 PM
So you would use the one txt file and just add the urls to that txt file like this?
http://www.google.com
http://www.yahoo.com
etc
and call them like this .
myURL[1], myURL[2]

Ok that works great , how do I load it into the web1 then?

Corey
02-08-2006, 10:35 PM
Yes, that's what I'd do for something like this. To lead the URL into the web object just change the action in the example, I set it up using File.OpenURL. You can change that to any action you like, the main point to note being that I used a variable (myURLS[1]) to refer to the URL value, not a literal string. That is what makes it possible you load URLs dynamically. :yes

If you want to "protect" the text file somewhat you could even add it to an encrypted zip file and extract it from there at runtime, read it into memory, then delete it. It's not foolproof but it is enough to prevent casual looky-loos from lookylooing, or worse yet, altering your links. :D

As a follow up, you could also create a separate administration tool/page using AMS for parents to add/edit links inside the links file inside the encrypted zip file. Again, it's not unbeatable security but adequate enough to ward off any casual unsavoriness. :yes

If you need more security than that so that the links are never readable in plain text you could also work out a little system to scramble/unscramble them etc. At it's crudest level the metaphor here would be to say shuffle every second character forward by 3 characters, and then reverse the string. Or whatever, you get the idea, obfuscating the text so that even if people have access to the text file they can't just casually modify links. The real king of this sort of thing is Lorne, if you ever get to the point where you are seeking to implement some encryption or security, he's the guy to ask for sure. And he has vantastic taste in mountain bikes too, so that's a bonus. :D

bobbie
02-08-2006, 10:49 PM
Thanks Corey you have been so much help . I got it to work with this Web.LoadURL("Web1",myURLs[2], SW_SHOWNORMAL); and got it on the first try . Almost sh*t my pants. lol
I can code something up to edit the file with in Autohotkey as I know that well .
I don't think I need to go as far as encrypting the file .
Thanks so much for the help.

Corey
02-08-2006, 11:37 PM
No problem. :)

bobbie
02-09-2006, 12:11 AM
Working on the link editor , how does it look so far.
When it opens it will have the links load and ready to be replaced.

yosik
02-09-2006, 12:14 AM
Bobbie,
It looks slick and professional.
Good work!

Yossi

Corey
02-09-2006, 12:23 AM
I agree with Yossi, this looks slick. :yes

bobbie
02-09-2006, 12:31 AM
Thank you .. now to do the coding . I may get some help with this .time to call my buddy . lol.

Roboblue
02-09-2006, 02:16 AM
I have done a user link input an save that uses the sqlite plugin. It would take me 30 minutes to break it out of the project as a stand alone, so if you want to see it, let me know.
I use the database in a useful links popup in the project. It can be passworded so only the adult can make the changes.

Eagle
02-09-2006, 02:23 AM
Slick bobbie :cool

bobbie
02-09-2006, 04:56 AM
I have done a user link input an save that uses the sqlite plugin. It would take me 30 minutes to break it out of the project as a stand alone, so if you want to see it, let me know.
I use the database in a useful links popup in the project. It can be passworded so only the adult can make the changes.
Thanks ,I sure would like to see it if you want to do it.

bobbie
02-09-2006, 09:11 AM
Sorry to be a pest , I want to open the txt file that will hold the links from the url.txt.
So I have tried the paragraph object and that loadss the info fine from the txt file but I can't seem to find how to use that to edit the file.
I have tried listbox object but it didn't load the txt file ( not sure if I had it right) So what do I use to the load the txt file abd able to edit it and save it back the new links that have been change?

Brett
02-09-2006, 10:01 AM
Use an Input object with the multi-line option truned on.

fossil
02-09-2006, 10:36 AM
Yes and then you can use TextFile.WriteFromString to write it back to your txt file.

bobbie
02-09-2006, 10:53 AM
Hi, I have been trying with the textswap file but not having much luck, if someone has some free time could they look at this and see what I have wrong?
I change from html to txt file and now it won't work.

TJ_Tigger
02-09-2006, 11:12 AM
Bobbie,

Can you export the entire project? File->Export will export as an .apz which can then be opened with all the resources of the project.

Tigg

bobbie
02-09-2006, 11:23 AM
Here ya go .

TJ_Tigger
02-09-2006, 11:36 AM
First thing I notice is that the file you read in to perform the search and replace on does not contain the text you want to replace. All but the url.txt file are empty.

Tigg

bobbie
02-09-2006, 11:38 AM
Ya I know how do I fix this ? could you do it so I can see it .Then I can do it myself .

TJ_Tigger
02-09-2006, 12:32 PM
Here is one way.


if Input.GetText("Input1") ~= "" then
strLink = Input.GetText("Input1");
TextFile.WriteFromString("AutoPlay\\Docs\\url.txt", strLink, true);
Web.LoadURL("Web1", "AutoPlay\\Docs\\url.txt");
end


This will get the text from the input and add it to the end of hte url.txt file and then open that file in the web browser. There is no management of the number of links or anything more complex. Simple you could use the above text to continue to add links to a file and then open that file in a web browser.

I see in an above screenshot that you have an editor you are working on. I would suggest that you use the action TextFile.ReadToTable to read each line into a table entry, then you could loop through the table and add the text from each entry to the screen you have above. Maybe something like this:

url.txt contains the following

http://www.indigorose.com
http://www.google.com
http://www.yahoo.com
http://www.cnet.com
http://www.digg.com
http://www.thisweekintech.com
http://www.newsvine.com


tbURLs = TextFile.ReadToTable("AutoPlay\\Docs\\url.txt");
if tbURLs then -- make sure the table contains data
for x=1,8 do --step through the eight possible entries
if tbURLs[x] then --make sure the entry in the table exists
Input.SetText("Input"..x, tbURLs[x]);--set the input text to the line contained in the file
--the above line assumes that your inputs are labeled from the top to the bottom numerically
-- Input1, Input2, Input3 . . . Input8
end
end
end

-- Then when you want to save the file you could do the opposite.

tbURLs = {}
for x=1,8 do
if String.TrimRight(Input.GetText("Input"..x), nil) ~= "" then --make sure the input is not empty
tbURLs[x] = Input.GetText("Input"..x);
end
end
TextFile.WriteFromTable("AutoPlay\\Docs\\url.txt", tbURLs, false); --set to overwright the file


Tigg

bobbie
02-09-2006, 12:38 PM
Thanks for all the help.
I will see if I can get this to work .

Roboblue
02-09-2006, 02:57 PM
Thanks ,I sure would like to see it if you want to do it.
OK, here is the example. Just customize it as you like.
Notes:
Global Function - FillLink_lst()
creates or opens links database, then populates the list box with the title.

Page On Show - Calls FillLink_lst()

Rest of the actions are on the buttons' On Click.

Notice that there is a link limit set on the Save button, presently set at six.

The Test button will check for connection and will give message if none exists.

To create new database, just delete links.db from the Docs folder, next time page opens, new database will be created.

bobbie
02-09-2006, 03:14 PM
Wow that rocks .. I owe you big time for that..
Thank youuuuuuuu
So much.

Corey
02-09-2006, 03:24 PM
I agree. That does rock. :)

Roboblue
02-09-2006, 03:26 PM
If you look at the remarks in the code, you'll see a bit of "personal touches" from just about everybody that frequents this forum.
Another community effort.

bobbie
02-09-2006, 04:36 PM
Just one question Roboblue.
What do I add in the Global Functions to fill the web1 ?
I found the function FillLink_lst() but not sure where and what to add for the web1 so it fills with the links.

Roboblue
02-09-2006, 05:56 PM
I am not exactly sure why you would want to show the links in a web object. My opinion is to reuse the link listbox, and the FillLink_lst global function.
To get the links to work from the web object, you would still have to create an html file with links to show in the web object.
Here, you can also open the address from the list box, either in the default browser, or the custom browser built into your project.
In this example, I have the link going to a simple custom browser in the list box's On Selection event.
There is a Page Start Timer action in the Page On Show event, and some code in the Page On Timer event. This is to show the URL of whatever page is presently displayed in the Browser in the address bar.
Notice that there is no user input on the address bar so you can only open links from the approved website. A + for a custom browser for a young persons application.

To use an external browser, just replace the
Page.Jump("Browser");
to
File.OpenURL(sAddress, SW_SHOWNORMAL);

I would give instructions in the Help file that when the links are created on the link edit page to use a title that describes the link content.
I have added a password dialog to jump from the Approved Links Page to The Link Edit Page. The password is Adult, case sensitive.

bobbie
02-09-2006, 06:06 PM
The web object in the from is the main web for the browser so I want the links to show in that and they just click them to go to that page . there are a few links on the top but most of the links would be in the main web1. see what I mean.
So I want to grab the links from the database and fill the web1 with them to be click on. can that be done?

bobbie
02-09-2006, 06:32 PM
I got it working , yaaaaaaaaaaaaaaaaaa
Thank you for all your hard work .

bobbie
02-09-2006, 06:58 PM
Little screenshot with the update you did .. works great ..
Thanks again for the help.

Roboblue
02-09-2006, 07:08 PM
Very nice!
Do you have the tool tips text set for the upper row icons?

Corey
02-09-2006, 07:12 PM
Nice work Roboblue! :yes Congratulations bobbie, looks great. :)

bobbie
02-09-2006, 07:20 PM
Very nice!
Do you have the tool tips text set for the upper row icons?
I can't seem to find that setting?
Right now it is showing at the bottom.

Roboblue
02-09-2006, 07:31 PM
I can't seem to find that setting?
Right now it is showing at the bottom.
Click on any object on the page. Over on the left the object properties. Down in the Attributes section, you see tooltiptext. Type in what you want to show when they mouse over the object.
It's also available if you double click an object and click on the Attributes tab in the object property window.
May save some confusion about the icons without labels.

bobbie
02-09-2006, 07:52 PM
May save some confusion about the icons without labels.
You can change the links on those so can't add a tooltip to them.

Roboblue
02-14-2006, 06:24 AM
bobbie
here is the thumblist object example you requested.
Code changes from the list to list are under the list box on select, and thumblist on double click. Be sure to look at the thumblist properties as you have to select file title to display only the title in the thumblist.
Some conditions to use this are:.
The images that are in the thumblist must be .jpg's. The .exe for the game must be in the same folder (have the same path as the jpg). The jpg AND the exe must be the same name (title).
With a bit more coding, you can remove the above conditions, but I don't have time to do it right now. This is the simple way.

You can get the updated apz HERE. (http://www.durotechs.com/download/gamelisticon.apz)

bobbie
02-14-2006, 09:45 AM
Thank you .. will take a look now.
On the cup there is an image but it didn't get to me so it can't display the image, what is the image?

Roboblue
02-14-2006, 10:15 AM
Thank you .. will take a look now.
On the cup there is an image but it didn't get to me so it can't display the image, what is the image?
In windows XP, that is supposed to show the user picture. It only works if you have added a pic that is not part of the default avatars.
One of the reasons it is just an example, I couldn't get it to work consistantly as it reads the info from the registry. I was going to put a bunch of avatars on a CD and make it so the user could add them from the app. My grandkids would have enjoyed it.
The cup was just an experiment to do gif like animation. AMS doesn't support gifs, so I was trying to see how I could simulate it.

bobbie
02-14-2006, 10:29 AM
Well that would of been cool if it work .. thanks for getting back to me when I know you are busy.