qb45advr.hlp (
Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
ASC Function Programming Example
◄QuickSCREEN► ◄Details► ◄Example► ◄Contents► ◄Index►
──────────────────────────────────────────────────────────────────────────────
ASC Function Programming Example
The following example uses ASC to calculate a hash value--an index
value for a table or file--from a string:
CONST HASHTABSIZE = 101
CLS 'Clear the screen
INPUT "Enter a name: ",Nm$ 'Prompt for input
TmpVal = 0
FOR I=1 TO LEN(Nm$)
' Convert the string to a number by summing the values
' of individual letters.
TmpVal = TmpVal + ASC(MID$(Nm$,I,1))
NEXT I
' Divide the sum by the size of the table.
HashValue = TmpVal MOD HASHTABSIZE
PRINT "The hash value is "; HashValue
Sample Output
Enter a name: Bafflegab
The hash value is 66