Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
48
Task/Binary-strings/FutureBasic/binary-strings-1.basic
Normal file
48
Task/Binary-strings/FutureBasic/binary-strings-1.basic
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
// Pascal Strings (limited to 255 characters)
|
||||
print "----------------------"
|
||||
print "Pascal String Examples"
|
||||
print "----------------------"
|
||||
|
||||
// Dimension strings and iterator
|
||||
Str255 s, a
|
||||
short i
|
||||
|
||||
// Create string
|
||||
s = "Hello, world!"
|
||||
|
||||
// Get length of string using length byte at 0 index
|
||||
print @"Length of \"Hello, world!\" is "; s[0]; @" characters."
|
||||
|
||||
// String destruction
|
||||
s = ""
|
||||
|
||||
// String comparison
|
||||
if s == "Hello, world!" then print "Strings are equal"
|
||||
|
||||
// Copying string
|
||||
a = s
|
||||
|
||||
// Check If empty
|
||||
if s == "" then print "String is empty"
|
||||
|
||||
// Append a byte
|
||||
s = s + chr$(65)
|
||||
|
||||
// Extract a substring
|
||||
a = mid$( s, 1, 5 ) // bytes 1 -> 5
|
||||
|
||||
// Substitute string "world" with "universe"
|
||||
a = "Hello, world!"
|
||||
for i = 1 to len$(a)
|
||||
if ( mid$( a, i, 5 ) == "world" )
|
||||
a = left$( a, i -1 ) + "universe" + mid$( a, i + 5 )
|
||||
end if
|
||||
next
|
||||
print a
|
||||
|
||||
// Join strings
|
||||
s = "See " + "you " + "later."
|
||||
print s
|
||||
print : print
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue