Monday, September 30

String Functions(String handling commands

String functions or string handling commands allows us to examine and modify tring and convert tring to numeric values.

  • The string function with a dollar sign($) at the end returns a string whereas a string function without a dollar sign returns a numeric value.
  • String operation allow combination and comparison of strings.BASIC has the following string manipulation function.
LEFT$ function

The LEFT$ function returns a string that comprises the left most n characters of x$.
Syntax
LN LEFT$*(x$,n)
Where,
LN  : Line Number
x$   : string from which n left most characters are to be returned.
n     : number of characters

  • The value of n must be within range of 0 to 255.
  • if n = 0, the null tring (length zero) will be returned.
Example

10 LET P$ = "GOLDEN RING"
20 LET Q$ = LEFT$(P$,9)
The LEFT$ on line 20 will return nine characters of P$ string. o Q$ will have the string.
Q$= "GOLDEN RI"
Use the LEFT$ function in the program.

(1)CS 8.1 Dissplay on the screen for LEFT$ function 

Ok
LIST
10 REM use of LEFT$ function
20 P$ = "GOLDEN RING"
30 Q$ = LEFT$(P$,6)
40 print "Original String - "; P$
50 PRINT "Extracted String  - ";Q$
60 END
Ok
RUN
Original String - GOLDEN RING
Extracted String - GOLDEN
Ok

(2)CS Display on the screen for LEFT$ function

Ok
LIST
10   REM use of LEFT$ function
20   LET A$= " KATHMANDU"
30   FOR I = 1 TO 9
40   PRINT LEFT$ (A$,I)
50  NEXT I
60  END
Ok
RUN
K
KA
KATH
KATHM
KATHMA
KATHMAN
KATHMAND
KATHMANDU
Ok





1 comment:

  1. Coin Casino | Get 100% Welcome Bonus of up to ₹10,000!
    Coin Casino is a 1xbet korean fun and friendly online gambling platform that is 인카지노 part of the Global Poker Network. 온카지노 You can play the entire game as a spin-off

    ReplyDelete