Tilbage - Programmering - Tegneserier - Tegninger - Sjov - Baggrundsbilleder - Jakob - Forsiden - send mail til mig


ViewPictures(baseImageFolderPath, imagesPerPage)

Description:
This function displays a little "browser" which lets your visitors browse through images in a folder. If the folder has subfolders, it also shows the number of images in those, and lets the user browse through those as well. It will only display image files (jpg, gif, png, etc...), so you can have other files in the folders as well. The function will look for a file called "comments.txt" in the imagefolders, and if it finds it, the function will display line number 1 under image number 1, line number 2 under image number 2 etc. You get the idea : )
The function lets you define an image to use as separator between images, the text for "previous" and "next" links (for you who, like me, have another first language other than english), and an image to display in front of folders. If the function doesn't find those images, it gets along without.
This is a really useful function. I use it for documentation where I dump images in a folder along with a textfile describing the steps, and for holiday photoalbums where I write the

Input:
baseImageFolderPath the relative path to a folder that you want to be displayed
imagesPerPage the number of images to display on each page

Output:
A little "browser" which displays the contents of a folder with images in a browsable form

See it in action

fileExists(filePath)

Description:
Checks to see whether a given file exists. It's basically a shortcut function, so you don't have to create a FileSystemObject to see whether a folder exists.

Input:
filepath the relative path to the file you want to check whether exists

Output:
true if the file exists, false if it doesn't

See it in action

folderExists(folderPath)

Description:
Checks to see whether a given folder exists. A shortcut function (see "fileExists" above).

Input:
folderPath the relative path to the folder you want to check whether exists

Output:
true if the folder exists, false if it doesn't

See it in action

getNumberOfLinesInFile(filepath)

Description:
Returns how many lines are in a given file

Input:
filePath the relative path to the file

Output:
the number of lines in the file

See it in action

getLine (filepath, lineNumber)

Description:
This function lets you read a specific line from a textfile. You can use it to read specific lines in configuration files. I use it in the ViewPictures function to read the comment line for a specific picture.

Input:
filePath the relative path to the file
lineNumber the number of the line to get

Output:
the corresponding line from the file

See it in action

getFileContents (filePath)

Description:
This function reads the contents of a file, and returns the contents as a string. It is very useful for showing the contents of a textfile in a <textarea> or displaying the code of an asp or html file.

Input:
filePath the relative path to the file

Output:
the contents of the file as a string

See it in action

getDataFileContents (filePath, commentPrefix)

Description:
This function reads a textfile but excludes blank lines and lines starting with the commentPrefix. The commentPrefix could be "//" (two slashes) or the "#"-character or whatever you need to read a file.
It is useful for reading your selfmade datafiles or datafiles from somebody else's project, that you have to parse or work with.

Input:
filePath the relative path to the file
commentPrefix the prefix that denotes a comment line

Output:
the contents of the file as a string

See it in action

function stringToHTML (input)

Description:
Converts a string to HTML. Basically the Server.HTMLEncode with the added functionality of inserting linebreaks as "<br>" with a linebreak to make easily readable code. It also indents by changing TABs to four non-breaking spaces (&nbsp;)
I use this function a lot on this page to display the contents of the "default.asp" file for you.

Input:
input the string to encode

Output:
the string encoded with "&lt;" for "<", etc.

See it in action

getFileAsArray (filePath)

Description:
Returns the contents of a given file as an array with each line from the file in its separate index in the array
Very useful for storing data in textfiles and then importing them for use in dropdowns, links, whatever. See the sample for ideas.

Input:
filePath the relative path to the file to get

Output:
An array of strings

See it in action

writeArrayAsFile(theArray, filePath)

Description:
Dumps an array as a new file.
This is a utility function for use in your own datamanipulation methods. It works well with the "getFileAsArray()" method to read a file as an array of strings - manipulate the lines (e.g. prefix them with "<br>") and write them again using this method.

Input:
theArray the string array to write
filePath the relative path to the file to write the array to

Output:
none

dumpAsFile(filePath, data)

Description:
Dumps a variable as a new file.
This is a utility function. It can be used to debug, for log purposes, to save text from an input field in a form, or anywhere you want to save something on disk.

Input:
filePath the relative path to the file to dump the data in
data the data to write

Output:
none

appendToFile(filePath, data)

Description:
Works almost like "dumpAsFile()" above, but with the difference, that if the file you want to dump to already exists, this method doesn't overwrite the existing file, but appends (adds) the data to the end of the file.

Input:
filePath the relative path to the file to dump the data in
data the data to write or append

Output:
none

getRandomLineFromFile(filePath)

Description:
Returns a random line from a specified file.
Very useful for "Quote of the day", etc. Make sure you don't leave any blank lines, and "glue" multiline quotes together with "<br>" tags.

Input:
filePath the relative path to the file to get a line from

Output:
A string

See it in action

getNumberOfFilesInFolder(folderPath)

Description:
Returns the number of files in a given folder
Very useful for any userinterface, where people can upload or download from a folder. This way - when browsing around they can always see exactly how many files are in any given folder (if you show them - of course : ))

Input:
filePath the relative path to the folder to count files in

Output:
The number of files in that folder

See it in action

getNumberOfFilesInFoldertree(folderPath)

Description:
Returns the total number of files in a given folder and all subfolders of that folder. Works almost like the "getNumberOfFilesInFolder()" above.

Input:
filePath the relative path to the folder to count files in

Output:
The number of files in that folder and all subfolders

See it in action

getNumberOfImagesInFolder(folderPath)

Description:
Returns the number of images in a given folder
Very useful for all sorts of galleries to show how many images are in the different folders. You can even mix the filetypes in the folders (have .txt or .zip files in the same folder) because the function only looks for files of the following types:
  • gif
  • jpg
  • png
  • bmp
  • jpeg
  • emf
  • tif
  • tiff
  • wmf
  • ico
  • pict
  • pcx

Input:
folderPath the relative path to the folder to count images in

Output:
The number of images in that folder

See it in action

getNumberOfImagesInFoldertree(folderPath)

Description:
Returns the total amount of images in a given folder and all subfolders of that folder. Very like the getNumberOfImagesInFolder() method above.

Input:
folderPath the relative path to the folder to count files in

Output:
The total number of files in that folder and all subfolders

getRandomImageFromFolder(folderPath)

Description:
Returns the path of a random image from a folder
Very useful for any sort of gallery, where you want a random image displayed as a "preview" for the collection.
I use it on my webpage (see the alternating, weird backgrounds?) in conjunction with "FindFolderByDate()" (below) to show random images based on the time of year.

Input:
folderPath the relative path to the folder to get a random image from

Output:
A string containing the path of a random image

See it in action

findFolderByDate(masterFolder)

Description:
Returns the path of a folder based on the date
This function will look in a folder you specify, and try to locate a subfolder that matches the current date (on the webserver). If it locates this folder, it will return this folder, otherwise, it will return a "default" folder.
This function is useful for any sort of website that has content which changes according to the date. With this function you can change the backgrounds on your website, the quotes or content, based on the current date. I use it to change the backgrounds on Jake.dk based on whether it is:
  • 31st of December or 1st of January (New year)
  • 14th of February (Valentine's day)
  • 9th of April (Denmark's occupation - World War II)
  • 5th of May (Denmark's liberation - World War II)
  • 6th of June (Danish Constitutionday)
  • 31st of October (Halloween)
  • 17th of November (Petzi's (Rasmus Klump - danish comicbook character) birthday)
  • 1st of December to 30th of December (Christmas)

Then I also have a "default" folder with all the usual wacky backgrounds ; ) The format of the folders should be: "mm-dd to mm-dd [name]" where the [name] isn't required, but a nice reminder for yourself.

Sample folders:
"02-14 to 02-14 ValentinesDay"
"10-31 to 10-31 Halloween"
"12-31 to 01-01 NewYearsDay"

You could also use this on a personal webpage where you put pictures on the page from your wedding on your wedding anniversary, from your birth on your birthday - etc.

Input:
masterFolder the relative path to the folder to look for datefolders in

Output:
A string containing the path of a folder that matches the date (if any) or the "default" folder

See it in action

isImage(filename)

Description:
Determines whether a given file is an image - based on the files suffix (the part after the period: .zip, .bmp, etc.)
Useful if you have a folder with mixed content, and you want to find only images (or only non-images)
This method is used by other methods in "jakes_io.zip" to find images in folders.

Input:
filename the relative path to the file to check

Output:
true if the file is one of these filetypes: gif, jpg, png, bmp, jpeg, emf, tif, tiff, wmf, ico, pict, pcx.
false otherwise

See it in action

getImagesFromFolder(folderpath)

Description:
Gets all the images in a given folder as an array.

Input:
folderpath the relative path to the folder to get images from

Output:
An array containing all imagefiles in the given folder

See it in action

getFilesFromFolder(path)

Description:
Gets all the files in a given folder as an array.

Input:
folderpath the relative path to the folder to get files from

Output:
An array containing all files in the given folder

See it in action

getFoldersFromFolder(path)

Description:
Gets all the subfolders in a given folder as an array.

Input:
folderpath the relative path to the folder to get subfolders from

Output:
An array containing all subfolders in the given folder

See it in action

writeSize(sizeInBytes)

Description:
Writes the size of something in a nicely formatted way.
For example 1280 Bytes =

Input:
sizeInBytes the size to convert

Output:
A nicely formatted string showing the size with Bytes, KiloBytes, MegaBytes or Gigabytes

See it in action

getSize(path)

Description:
Finds the size of the file or folder specified in the path.
If the path is a folder, then the bytesize of all files in all subfolders is returned
If the path is a file, then the bytesize of that file is returned

Input:
path the path to the file or folder to find the size of.

Output:
The total size of the file or folder, in bytes

See it in action (same sample as above with "writeSize()")

toLog(stringToSave)

Description:
Writes the string to a logfile. If a logfile exists - then the string is appended. If no logfile exists - then one is created and the string is written to it.
The logfiles automatically get named after year and month. Today a line would be written to a file named "logfile_2024_04.asp". The reason the logfiles are named ".asp" is that then they cannot be viewed by just any user. The logfiles have these two lines as the first :

<%response.write("Ahem ... you have nothing to do here!!")
response.end%>
This prevents anyone from typing the URL and viewing them.

Input:
stringToSave the string to put in the logfile

See it in action

toLogFile(fileName, stringToSave)

Description:
Writes the string to the specified logfile. If the logfile exists - then the string is appended. If the logfile doesn't exist - then the file is created and the string is written to it.

Input:
fileName the relative path to the logfile to use/create
stringToSave the string to put in the logfile

See it in action

getWrittenDate (Datestring)

Description:
Converts a date variabel to a written date.

Input:
DateString the date to write out

Output:
The date written out. E.g.

See it in action

showShare (share, maximum, widthInPixels)

Description:
Displays a percentage bar in HTML.

Input:
Share how much equals the part of the whole (e.g. 3 or 19)
Maximum how much equals the entire bar (e.g. 4 or 20)
WidthInPixels how wide should the bar be on the screen

Output:
The part converted to HTML

See it in action

count (byval nameOfCounter)

Description:
A very easy to use counter. It is based on a textfile ("counter.txt") which is placed in the same directory as the file calling the counter. "Count()" has two uses:
You can call it with an empty string count("") which will increment and store a counter based on the URL at this time.
You can call it with a counter name count("clicks") which will increment and store a counter with the given name

Input:
NameOfCounter the name of the counter (if any) that you want to increment

Output:
The new value for the counter

See it in action

getCounterValue (byval nameOfCounter)

Description:

Input:
NameOfCounter the name of the counter that you want to read the value of

Output:
The value of the counter

See it in action (same sample as above with "count()")

debugThis(value)

Description:

Input:
value the value you want to see in debug mode. This is very useful for debugging code. You can write out the value of a string, number, boolean or array in this way. The debugThis method executes response.end - so you can use it to break right before code that otherwise "crashes" the page.

See it in action

arrayToTable(anArray)

Description:

Input:
anArray if you want to see the contents of an array - use this function to convert the array to an HTML table and then response.write() it. This is very useful for debugging code.
This function is a utility function used by "debugThis()".

See it in action

filesToLinks(path)

Description:

Input:
path the path to the files you want to make "gettable" by adding links to them. I have used this function a lot when I teach classes. Often you need to share files with students, and having to change the HTML of a page everytime you upload something gets tedious. So this function takes a path to the files and creates links out of them.
The function does almost the same as "arrayToLinks()" below, but with the difference, that filesToLinks() only shows the filename not the entire path.

Output:
The files as links, on separate lines

See it in action

arrayToLinks(theArray)

Description:

Input:
theArray the array containing whatever you want to make into links.
The function converts the contents of an array into links. It works well with GetFilesFromFolder(), GetFoldersFromFolder(), GetImagesFromFolder() and GetFileAsArray().

Output:
The contents of the array as links

See it in action

getFilename (path)

Description:

Input:
path the path to a file
The function returns only the filename part of a path. For example getFileName("graphics/folders/hotfolder.gif") would return only "hotfolder.gif".

Output:
The filename from the path

delete (byval path)

Description:

Input:
path the path to a folder or file.
Delete() deletes a file or folder.


Tilbage - Programmering - Tegneserier - Tegninger - Sjov - Baggrundsbilleder - Jakob - Forsiden - send mail til mig