Mid
ASCII_Code = Mid(InputString$, CharacterPosition)
 
Parameters:

    InputString$ = The string you want to read the ASCII values from
    CharacterPosition = The position of character you wish to query from the input string
Returns:

    ASCII_Code = The ASCII code the represent this character
 

      The Mid() function allows you to grab the ASC II value of any character from within the InputString$



FACTS:


      * Mid() returns the ASC II value of a character. It's a short cut for the following ThisChr=asc(mid$(InputString$,Pos,1))





Mini Tutorial:


      Examing the ASC II values within a string is normally done by using the MID$() function to grab a single character and then converting the returned character to it's ASCII value using the ASC function. So Mid() is really shorthand for that..


I.e. Here's how we used do this.

  
; OLD WAY
  Print "getting ASCII codes using MID$ and ASC"
  Number$="ABCDPlay Basic"
  
  For lp =0 To Len(number$)
     Print Asc(Mid$(Number$,lp,1))
  Next
  
  
; New WAY with this special Mid function
  Print "getting ASCII codes using MID short cut"
  
  Number$="ABCDPlay Basic"
  For lp =0 To Len(number$)
     Print Mid(Number$,lp)
  Next
  
; Show Screen
  Sync
  WaitKey
  
  


      In this mini example, both loops step through string number$, grabbing each character and then displaying it's ASCII value. The mid() is just a little cleaner for what is fairly common process. So mid() is a shortcut.

Sample output

  
  getting ASCII codes using MidAnd Asc
  65
  65
  66
  67
  68
  80
  108
  97
  121
  32
  66
  97
  115
  105
  99
  getting ASCII codes using Mid short cut
  65
  65
  66
  67
  68
  80
  108
  97
  121
  32
  66
  97
  115
  105
  99
  

 
Related Info: ASC | Left$ | Mid$ | Right$ | Val :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com