PDA

View Full Version : How to browse for and open file in ams5?


hammerstein
02-10-2005, 06:40 PM
Hi:
I'm having a little trouble getting ams5 to browse for a local .htm file and then opening it in web browser object. In ams4 i used a dll, but i don't know how to use the dll in ams5. Can I browse for local htm file and open it without using dll in ams5? Any code examples would be much appreciated. Thank you,
Hammerstein

Josué Alba
02-10-2005, 07:46 PM
well yoy can use the File.Open action. it should be something like this.


File.Open("AutoPlay\\Docs\\index.htm", "", SW_MAXIMIZE);

hammerstein
02-10-2005, 08:08 PM
I need to be able to browse for file, i.e. select file at time of opening, not a already determined page...

Thankx ;)

Intrigued
02-10-2005, 08:13 PM
Here is a link to the online web help for I.R./AMS 5 that may be of help:

http://www.indigorose.com/webhelp/ams50/Program_Reference/Actions/Dialog.FileBrowse.htm

and...

http://www.indigorose.com/webhelp/ams50/Program_Reference/Actions/Dialog.FileBrowse_Examples.htm

hammerstein
02-11-2005, 12:47 PM
Can someone show me a working example, wherefrom I can see exactly how it is done to get me started. For example, I want to browse for a local html file and then open it in web browser object after choosing the file. Unfortunately examples given online with ams help result in string errors etc. I'm still new to this, and just need a working example wherefrom I can see exactly how it is done. Thanx much.

JimS
02-11-2005, 01:15 PM
Here is a little example for you. :)

Worm
02-11-2005, 01:22 PM
Here's some code to try


--Browse for a file. This action returns a table. This particular call, limits the slection to
--one, so the table will only have 1 element. If that first element is = "CANCEL" then the user
--didn't choose a file

--Browse for file
tblFile = Dialog.FileBrowse(true, "Select the HTM or HTML file to open", "", "HTM Files (*.htm)|*.htm|HTML Files (*.html)|*.html|", "", "htm", false, true)

--Test to see if the user canceled, if so, don't process
if tblFile[1] ~= "CANCEL" then
--check the filename to see if it is a HTM or HTML file
if String.Right(String.Upper(tblFile[1]),3) ~= "HTM" then
if String.Right(String.Upper(tblFile[1]),4) ~= "HTML" then
--Show dialog indicating that they didn't choose a HTML or HTM file
nResult = Dialog.Message("Invalid File Type", "Please select only HTM or HTML files.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
--exit this script
return
end
end
--load the file into the web object
Web.LoadURL("Web1", tblFile[1])

end


JimS is faster'n me

Intrigued
02-11-2005, 01:25 PM
Here's some code to try


--Browse for a file. This action returns a table. This particular call, limits the slection to
--one, so the table will only have 1 element. If that first element is = "CANCEL" then the user
--didn't choose a file

--Browse for file
tblFile = Dialog.FileBrowse(true, "Select the HTM or HTML file to open", "", "HTM Files (*.htm)|*.htm|HTML Files (*.html)|*.html|", "", "htm", false, true)

--Test to see if the user canceled, if so, don't process
if tblFile[1] ~= "CANCEL" then
--check the filename to see if it is a HTM or HTML file
if String.Right(String.Upper(tblFile[1]),3) ~= "HTM" then
if String.Right(String.Upper(tblFile[1]),4) ~= "HTML" then
--Show dialog indicating that they didn't choose a HTML or HTM file
nResult = Dialog.Message("Invalid File Type", "Please select only HTM or HTML files.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1)
--exit this script
return
end
end
--load the file into the web object
Web.LoadURL("Web1", tblFile[1])

end


JimS is faster'n me

It's the quality and not the speed Worm! :D

*I have learned this the hard way, ouchy!

JimS
02-11-2005, 01:28 PM
I just realized that you want to be able to search for both .html & .htm files

To do that, you could change this line:

result = Dialog.FileBrowse(true, "Locate HTML File", _DesktopFolder, "HTML Files (*.html)|*.html|", "", "html", false, true);

to this:

result = Dialog.FileBrowse(true, "Locate HTML File", _DesktopFolder, "HTML Files (*.htm or *.html)|*.htm*|", "", "htm*", false, true);

JimS
02-11-2005, 01:42 PM
It's the quality and not the speed Worm! :D

*I have learned this the hard way, ouchy!


That’s a fact. ;) He and I were just discussing something like that the other day.

Worm’s code is commented and contains error correction :yes , my example is just a simple 2 lines, no comments or error trappings. :eek:

I’m sure that Worm would have posted before me if he would have taken the same shortcuts I did.

I’m just trying to help field the easy questions so Worm has more time to answer the tough ones. :)

Intrigued
02-11-2005, 01:48 PM
What I just learned about that code Worm posted (thanks!) is another way to look at code via way of his use of the return built-in to break out of the code!

That's just plain cool!

Intrigued
02-11-2005, 01:52 PM
One tweak I believe I would change Worm... instead of two seperate entries in the dropdown dialog (to choose the .html and .htm files); I would use a single line and have (.htm, html) sort of setup.

Minor detail to be sure, but it seems that is what a tipical dialog like that would do.

Worm
02-11-2005, 03:17 PM
Yep, I would too, except I was racing JimS to answer and totally over-looked it :)

JimS
02-11-2005, 03:43 PM
Worm,
You know that I’m not one to ever brag or rub it in, and I’d never toot my own horn about winning a race. So, this is strictly as a public service reminder for our friends keeping score at home

JimS 1
Worm 1,740

Don’t give up or be too hard on yourself, I don’t want this loss to keep you up all night worrying. Keep on practicing and maybe you’ll have better luck next time.
:)


.

Worm
02-11-2005, 03:47 PM
I the words of Corey; "Hee!" :D

Intrigued
02-11-2005, 04:03 PM
:p

Now, it's time for the picking (er, curtiquing) of my code (in part). So, in all fairness... here is my update on your code Worm.

hammerstein
02-11-2005, 05:41 PM
Warm thanks to all that contributed. I finally get the idea of how ams5 works now. I spent so much time with ams4, then when I switched to ams5 I was completely lost. I been reading about the syntax construction and so forth, but sometimes u need an example to get started. Thanks to all of you for helping, now I can proceed with my project.

SUF6NEWBIE
02-11-2005, 06:15 PM
JimS 1
Worm 1,740

change that to:

Coyote 1
RoadRunner 1740

;)

..just following the 'theme' of the Cartoon..

..did they ever show the Coyote getting the better of Roadrunner ?

JimS
02-11-2005, 06:29 PM
That’s pretty good SUF6Newbie,
I’ll take that any day. As far as I know, it gives me one up on Wiley.

You’ll notice that I only gave Worm credit for 1,740 when he has actually made at least 1,745 posts. That’s because he has spent 5 of his posts just chatting, rather than posting code to help someone.

I think he does that just to run up the number of posts he’s made. You know, put that extra 5 post padding, just so he can keep ahead of me.
:lol

Corey
02-11-2005, 06:49 PM
That’s because he has spent 5 of his posts just chatting, rather than posting code to help someone.


I count 6 actually but I'm inclined to give Worm the benefit of the doubt due to his longstanding ambassadorship of the French Horn and simultaneous usage of the word "hub-bub". I mean, surely that counts for *something* in this day and age doesn't it?

SUF6NEWBIE
02-11-2005, 06:55 PM
one more for me :yes

hey.. new idea for a movie

Title: Wiley makes Good

coming to a cinema near you..reckon it would make an absolute killing
in box office returns. Lets do it !!!!

JimS
02-11-2005, 07:35 PM
..reckon it would make an absolute killing...

Good pun :yes

Yea, just once I’d like to see old Wiley, with a full belly, relaxing while tying trout flies out of the pile of left over feathers.

I’d bet he could get some great hits out of those blue and purple flies. Of course, with his luck, he’d end up snagging his own tail and casting himself rump-over-tea-kettle.

On second thought, maybe he would be better off doing what the cowboys around here do with their extra feathers, fashion them into a spiffy hatband.


.

JimS
02-11-2005, 08:04 PM
Corey, you’re right. I just added them up again, and noticed that I had forgotten to carry the 1. I never was any good at long division.

French Horn and linguistic mastery aside, 6 fluffy posts, means that only about 99.997% of his posts are of high value. That means that mathematically, he’s going to have to make quite a few more valuable posts, if he ever expects to raise his signal to noise ratio in any appreciable way.

Yes, it’s true, I didn’t have anything important at all to add to this thread, I’m just posting to bump my number up. I just have to do this sort of thing about 1100 more times, and then some of the newbies might think I’m in the same league as members like Worm and Tigger. :D


.
Edited to change 99.97% into 99.997%, told you I wasn't any good at long division :)

Corey
02-11-2005, 08:14 PM
5910 schwink! :yes

JimS
02-11-2005, 08:56 PM
5910, That’s a lot of posts Corey. It’s enough that Indigo Rose ought to start paying you. Hang tight, I’ll see what I can do about that. I can’t make any promises, but I’ll see if I can pull a few strings for you. After all, I have read nearly all of Darryl’s posts, so I figure that we are like this (crosses fingers). When I combine my long standing friendship with Darryl along with the fact that just a couple of months ago, I saw a picture of IR’s headquarters, then I figure that Colin will more than happy to hear me out.

I have a good feeling about this, I’m sure that always being on the road must get awfully hard, I’ll bet that pretty soon you’ll be able to retire from skateboard exhibitionions, and earn a real living from Indigo Rose. Incidentally, I hear that they are a wonderful company to work for. After all, what in the world could be better than actually getting paid for all the fun you have here at the forums.

Just kiddin’ big guy, seriously that is a lot of posts. I figure that about half of my posts have been racked up from just a couple of our late night discussions.

Now I only have 1099 more posts to go. (I think that all of us gave up on ever trying to catch up with Corey)

Corey
02-11-2005, 09:06 PM
I'm living the dream baby, no question about that. Makes me feel guilty knowing how hard so many people have it everyday. Not a day goes by that I don't spend at least an hour or two thinking about it. :o

Anyhow I can guarantee you that Worm has a *much* higher rate of relevancy in his posts than I do. He's one of those guys who doesn't talk unless he has something to say, whereas I am a complete monkey. So that should probably be factored in. One of Worm's posts is generally worth about 10 of mine, except during the fall fashion season when he tends to become completely distracted by the new lines from NY.

Derek
02-11-2005, 09:10 PM
I've given up in the race. I remember moons ago i had well over a thousand posts and half of em got zapped during a change-over or something.
Now it's a joke to try, especially when Corey is close to a googol :eek:

Corey
02-11-2005, 09:15 PM
Derek, you're O.G. to the real players. Old skool. :yes

JimS
02-11-2005, 11:01 PM
...i had well over a thousand posts and half of em got zapped during a change-over or something...

I think that that has something to do with the Euro/Canadian exchange rate. Correct me if I'm wrong, but isn't 1 euro worth about 3 Canadian :)

Derek
02-12-2005, 05:59 AM
I think that that has something to do with the Euro/Canadian exchange rate. Correct me if I'm wrong, but isn't 1 euro worth about 3 Canadian :)
lol .. very good JimS :)

Currently its about 1.6 - aannyywwaayy, the UK doesnt use Euro's ;)
We use the strongest currency on the market .. the Pound GBP :)
[All in jest, of course!]

Corey
02-12-2005, 06:02 AM
Yeah the UK was pretty adamant about the Euro as I remember. :)

Derek
02-12-2005, 06:16 AM
Yeah the UK was pretty adamant about the Euro as I remember. :)
Yeah! Dunno why tho .. can't see the big deal really. Got to be something to do with de-valuing our currency and the economy generally. As long as I can earn it and spend it I dont care what it looks like :)
I'm sure there was this issue about having the Queen's head on the Euro too. Like we care! A majority of the population wouldnt give a hoot if the monarchy went forth .. to somewhere else, i'm sure. The only thing they are good for is tourism. But who likes ism's anyway?

Corey
02-12-2005, 07:20 AM
No doubt. Well rest assured, we are no better off than you in terms of leadership. Here in Alberta we have a complete sociopath running things:

http://www.wsws.org/articles/2001/dec2001/can-d22.shtml
http://www.theglobeandmail.com/servlet/Page/document/v4/sub/MarketingPage?user_URL=http://www.theglobeandmail.com%2Fservlet%2FArticleNews%2F TPStory%2FLAC%2F20040508%2FKLEIN08%2FTPNational%2F Canada&ord=1108214145649&brand=theglobeandmail&force_login=true
http://crofsblogs.typepad.com/ckbetas/2004/05/alberta_premier.html
http://www.ctv.ca/servlet/ArticleNews/story/CTVNews/1063752491832_59161691/?hub=Canada

He's a complete banana-cake. Never met a single person who supports him. No one here cares about anything though. People here can't even name the candidates at election time. We had single digit turnout for our last municipal election. :)

TJ_Tigger
02-12-2005, 09:24 AM
Yeah the UK was pretty adamant about the Euro as I remember. :)

So is Switzerland.

Corey
02-12-2005, 09:50 AM
A number of nations have re-pegged their currencies away from the greenback onto the Euro in the past few weeks, causing it to take on vastly increased importance. The coming months will be huge for the Euro.