Quote from: Frank Brübach on May 13, 2024, 05:51:20 PMHello all 👋
Made Last days for me an important Update of HalPromentBasic ...
I have changed some functions and Keywords.. its running all on a 64-bit machine now too
Halpromide Editor Shows at the start a Photo of the Stanley Kubrick film 2001 space odyssee because the hal Name belongs to this movie
' -- recursive function, halProment
''-- a) Case (n = 0) : factorial(0) = 1
''-- b) Case (n > 0) : factorial(n) = n * factorial(n-1)
''-- b) this case calls the function itself: 'Return n * factorial(n - 1)
Function recursiveFactorial (ByVal n As Integer) As Integer
If n = 0 Then '' end condition
Return 1
Else '' recursion loop
Return n * recursiveFactorial(n - 1) '' recursive call
End If
End Function
Printy recursiveFactorial(4) ' 24
p? recursiveFactorial(6) ' 720
' -- when a number is assigned to a string, it autoconverts.
' -- halProment Basic
' --
pro flag=10
flag++
printy flag '11
' number to an increasing string
'1)
pstring s="200mona"
s=val(s)+1 '201
printy s 'result: "201"
'2)
pro k
k++
s=val(s)+k
printy s 'result: "202"
'3)
pstring m=" Mona"
pstring st="3000 " + m
st=val(st)+1
printy st + m 'result: 3001 Mona
'4)
pro km=100
km++
pstring m=" Mona"
pstring st="3000 " + m
st=val(st)+val(km)+1
printy st + m 'result: 3102 Mona
' -- convert from freebasic, april-mai 2024
' -- simple example string / zstring halProment Basic
' -- Generatíng a string of n repeated characters
'
function generateRepeatedChar(character as string, n as Integer) as string
dim result as pstring = ""
dim i as integer
for i = 1 to n
result = result + character
next
return result
end function
' Example usage
dim repeatedString as pstring
repeatedString = generateRepeatedChar("*#", 5)
printy repeatedString ' Output: *#*#*#*#*#
' Create a zString
dim zString as pstring = ""
printy len(zString) ' Output: 0
'In this case, zString is an empty string,
'meaning it contains no characters.
'The length of zString is zero.
dim zString as pstring = "hey"
printy len(zString) ' Output: 3
'
' -- array index redim ubound lbound example
' -- halPromentBasic, mai-2024,frank bruebach
'
pindex 1
dim MyArray(10) as integer '1 TO 10
dim i as integer
' Fill the array with some values
for i = LBOUND(MyArray) to UBOUND(MyArray)
MyArray(i) = i * 10
next i
' Display the values in the array
for i = LBOUND(MyArray) to UBOUND(MyArray)
printy "MyArray(" + str(i) + ") = " + str(MyArray(i))
next i
' Re-dimension the array to have 15 elements
redim integer MyArray(15) '1 to 15
' Fill the new array elements with some values
for i = UBOUND(MyArray) - 8 to UBOUND(MyArray) '- 4 ' -10
MyArray(i) = i * 5
next i
' Display the values in the re-dimensioned array
for i = LBOUND(MyArray) to UBOUND(MyArray)
printy "MyArray(" + str(i) + ") = " + str(MyArray(i))
next i
' ends
Page created in 0.221 seconds with 11 queries.