does someone know VBScript?

For everything that's not in any way related to PureBasic. General chat etc...
Uncle B
User
User
Posts: 82
Joined: Mon Jan 12, 2004 11:28 am
Location: the Netherlands

does someone know VBScript?

Post by Uncle B »

Hi all!
Just a little question about creating webpages in MS word.
I'd like to use the below code to count the number of pagehits.
It runs fine when i run it from the MS Script editor in word, but when i save it to a *.html file the script doesn't seem to run at all and i get a message in the statusbar of Internet explorer that the page is loaded but with errors.

I'm totaly lost here, could someone help me out?

regards, Bart

Code: Select all

<script language="VBScript"  runat="server" TYPE="text/vbscript">
function CountHits()
dim readline,OldVal
dim fso, MyFile
dim count
dim ACount
set fso = CreateObject("Scripting.FileSystemObject")
set MyFile = fso.opentextfile("H:\Werkplaats\Procedure web\Main_files\TotalCount.txt",1)
count = MyFile.ReadLine
count = count+1
MyFile.Close

set MyFile = fso.CreateTextFile("H:\Werkplaats\Procedure web\Main_files\TotalCount.txt",true)
MyFile.Writeline(count)
MyFile.Close

ACount = Cstr(count)
document.write(ACount)
end function
CountHits()

</script>
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Inside Internet Explorer the FileSystemObject does not have any rights to write files to the HD of a user!!!!! If you change your security settings of the IE, than it would work. But you can not change the security settings of other users on other PCs ... AND THIS IS GOOD!

With your script you only can count your own hits. The only way to count ALL hits of a WEB page is to use CGI scripts on the server, where the WEB page is hosted.

cu, helpy

[edit]
SORRY .. i did not saw the attribute runat="server"
[/edit]
Last edited by helpy on Wed Mar 24, 2004 11:08 am, edited 1 time in total.
dmoc
Enthusiast
Enthusiast
Posts: 739
Joined: Sat Apr 26, 2003 12:40 am

Post by dmoc »

At a guess, check the path, ie, is it correct when run on the server and/or will the server accept spaces. Can you check the server for more descriptive errors? Have you enabled "script debugging" on your browser?
User avatar
helpy
Enthusiast
Enthusiast
Posts: 552
Joined: Sat Jun 28, 2003 12:01 am

Post by helpy »

Hi Bart,

Some questions:
  • How do you call the html page in IE? Which address do you use ... the local path ... or the internet/intranet address of the file?
  • You saved the file with extension html. Does the Server parse html-Files as "Active Server Pages". Maybe try to save the file with the extension *.asp!
cu, helpy
Uncle B
User
User
Posts: 82
Joined: Mon Jan 12, 2004 11:28 am
Location: the Netherlands

Post by Uncle B »

Hi, thanks for the replies so far.

eeehhh...

I gues i'm calling the page from a local path...

this isn't a real website, it's just a bunch of htm files in a network folder on the local intranet. IE loads the files from that directory.

One more question: what is exactly the diffrence between a htm/html file and a asp file, and do you need some kind of compiler for creating asp files?

well thanks so far
regards,
:roll: Bart
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

htm and html files are both identical. They contain a web page described in HTML: Hypertext Markup Language.

An ASP page is an Active Server Page. This is a template page that is used to generate HTML, and sometimes XML.

It works something like a MailMerge in Word. When the page is requested it is loaded by the ASP preprocessor, which finds the parts that are either marked <% and %> or within a <script runat="server"> tags.

These parts of the code contain code that is executed. They will write text to the response object. This text will then appear in the final web page.

Their is no need to compile the web pages. All that is need is to have IIS on the server.


A good tutorial for using ASP can be found at w3schools.

I wouldn't recommend trying to create asp pages in Word. Take a look at Citydesk


Before going down the ASP path I would strongly recommend investigating PHP.

It is much more powerful than ASP. It is also still supported. Microsoft have now moved on to ASP.net so for classic ASP, as for classic visual basic, future support is uncertain.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Hi Uncle B.

If you're used to coding in basic, then you'll quickly catch on to traditional asp as it is basically VB script adapted for serverside scripting.

Traditional asp does not compile.

It is powerful enough that you can do just about anything with it, operating within the limitations of the "user interface" being a webpage and the operating environment being within a webserver. I wrote a script to create on-the-fly swf, based on shapes and features requested by users. So it has capability - but that was also a slow process.

The .net version is a more complex - but still VB - and is majorly more powerful than traditional, and it does "compile" automatically.
fonkfonk
New User
New User
Posts: 9
Joined: Mon Oct 06, 2003 10:50 am

Post by fonkfonk »

Well, is it worth "playing that game" (programming with Vbscript ) ?

As Helpy stressed it, VB script should'nt be used as a programming language (IMHO, any script kiddy would enjoy messing around with a PC where VB Script runs ...).

I'm not even sure that a proxy can be a good protection against intrusions ...

Personaly, a few years ago (before the Virus I love You popped up), I planned to develop with VBS ... and quickly abandonned this idea ...

If this is definitely your choice, go for it ... :wink:
Pierre
Post Reply