Example Intro and HalPromIde24

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Hello all..

Some code example you can find Here and try to use... All example I added in ZIP and rar folder... If you have questions please ASK...

For Testing an example you can Push the "Quick Run" Button .. the Files you can save and load have *.habas endings.

Many thanks Theo for installing this new SUB Board and Charles for His great oxygen Basic language I could study the Last month and years during Corona time and Last year

Dont forget I am Hobby programmer Not  a Professional one.. the IDE iS 80 percent ready
I will improve IT step by step.. at the Moment its all in Interpreter modus

Creation building exe File will come too  IT Works already but I must Test all again

If you are starting the HalPromide24 Type in First some Text in console window to start the the HalPromide  IDE for Further working

I have added minimal Version of HalProment Basic 32 Bit , more will come later

First of all a Pic of the HalPromIde24  and an example with simple calculation

' simple calculation 2
' legend :
' dim = pim, dword = pro
' printy = print
' pstring = string
'
pim a,b,c,d as pro
a= 10 : b=20 : c=40 : d=a*b
printy a
printy d
pstring s = "Hello Batman " + a ' 10
printy s
pstring st = "Hello Spiderman " + d ' 200
printy st

pim k as float
k=2345.67 '2345.6699
printy k

Update of ZIP and rar folder 26-04-2024
Update Editor and DLL
  •  

Frank Brübach

#1
Next example for... Next and do... Loop

' -- expl 1
' -- for...next
'
dim i as integer, height as integer
height = 5
FOR i = 1 to height
  printy string(i, "*")
next
printy "after loop the value i has value " + i

'
'-- expl 2 do...loop
'
dim n as integer, even as integer
Do
  n += 1
  If n > 7 Then Exit Do
  If n Mod 2 Then Continue Do
  even += 1
Loop
Printy "even number: " + even
  •  

Frank Brübach

#2
Function examples Here factorial and quattro

'
' two function examples, factorial, quattro

' -- example 1
Function factorial(x As Integer) As Integer
    ' This is a recursive function
    ' to find the factorial of an integer

    If x = 1 Then
        return 1
    Else
        return x * factorial(x-1)   
    End If
End Function

printy factorial(4) ' 24

pim num As Integer
    num = 3
Printy "The factorial of " + num  + " is "  + str(factorial(num) )


' -- example 2
function quattro(i as pro) as pro
  return i*4
end function

printy quattro(4) ' 16
  •  

Frank Brübach

#3
Class examples 2x


'-- class example two times
'
'---------------------- //

class myZooClass

pApe as long

method ABC(value as long)
pApe = value
end method

method ABC() as long
method = pApe
end method

end class

'test it
dim zoo as myZooClass

zoo.ABC = 6
print zoo.ABC ' 6

'---------------------- //

class AnimalClass
tiger as long

method paw(claws as long)
tiger= claws
end method

method paw() as long
method = tiger
end method

end class

'test it
dim cat as AnimalClass

cat.paw = 5
print "catpaw " +cat.paw ' 5
  •  

Frank Brübach

#4
Next calculation example 2

long a,b,c,d
string st
a=20 : b=30 : c=40 : d=c*a
print d '800

st = "Hello result: " + str(d)
print st

pro a,b,c,d
pstring st
a=20 : b=30 : c=40 : d=b*a
printy d '600

st = "Hello result2: " + str(d)
printy st '600
  •  

Frank Brübach

#5
Next calculations and arithmetics

' Calculations

printy 1+2+3+4 '10

printy 1* 2* 3* 4 '24

printy sin(2* 4* 6* 8) '0.6636

printy cos(2* 4* 6* 8) '0.748

  •  

Johan Klassen

hello Frank  :)
HalProment Basic is written in C# ?
can you make a 64-bit build ?
  •  

Frank Brübach

Hello Johan.. No only a Part in c++, freebasic and oxygen .. I use next week another Notebook with 64 Bit and try to make a Test but I am Not Sure If thats running Well so far
Thx, Frank
  •  

Frank Brübach

Here an enumeration example

' enumerations
'
enum allmythings
   cars
   pets = 6
   paintings
   toys
   potatoes
   kings
   throne = 20
   sword
end enum

print paintings ' 7
print  sword  ' 21
  •  

Frank Brübach

Here a simple Iteration example

'-- string checksum example
 '
  dim abc,k as long
  dim st as string = "Avengers"

  abc=0
  for k=1 to len(st)
    abc+=asc(st,k)
  next

 print abc '827
 print st
 print k ' 9
  •  

Frank Brübach

Simple macro example

'-- simple macro
'
macro Adds(x,y)
  x + y
end macro

printy Adds("Hello my ", " Animal World")
printy Adds(2, 4) '6
  •  

Frank Brübach

#11
Simple Type example

'-- simple type example

type thor
  one  as byte
  two  as byte
  three as byte
  four  as byte
  five as string
end type

thor hammer
hammer.one=20 : hammer.two=40 : hammer.three=60 : hammer.four=80 : hammer.five="heroe"

print hammer.one
print hammer.two
print hammer.three
print hammer.four
print hammer.five
  •  

Frank Brübach

Array overlay example Translation from Powerbasic to halProment Basic


'-- halProment Basic / Powerbasic, 25-04-2024
'-- ArrayOverlay old powerbasic expl

type DynamicArrays
    doubles as pro
    singles as pro
    longs   as pro
end type

function PBMAIN () as long
    static d  AS DynamicArrays
    static ds as pstring
    static ss as pstring
    static ls as pstring
    '----------------------
    'create space
    ds=string(&h08000,chr(0))
    ss=string(&h04000,chr(0))
    ls=string(&h04000,chr(0))
    '----------------------
    'store pointers
    d.doubles=strptr(ds)
    d.singles=strptr(ss)
    d.longs  =strptr(ls)
    '----------------------
    'overlay
    static double dn(&hfff) at d.doubles
    static single ss(&hfff) at d.singles
    static long   ll(&hfff) at d.longs
    dn(3000)=1234.5
    '-----------------------
    'redimensioning technique
    ds+=string(&h02000,chr(0))
    d.doubles=strptr(ds)
    '-----------------------
    printy dn(3000)
end function

pbmain() '1234.5
  •  

Frank Brübach

This is a Short Substitute for Print message

' short substitutes for print, d and p
' halProment Basic 26-04-2024

dim a as long
dim s,st as string

s = "Hello Batman"
st = "Hello Spiderman"

d s 'GO 'd = "druck" german language for print

p st 'GO ' p = "print" only an abbrevation
  •  

Frank Brübach

#14
Hello again

Here a class Type example conversion from freebasic with cast to halProment

The freebasic Code you can find below my conversion

' convert a freebasic type class constructor to halProment Basic
'
class MyHeroeType
   bstring myString

method Constructor(string stParam)
   myString = stParam
   printy "construct"
end method

method destructor()
===================
'destroy bstrings
del mystring
printy "destruct!"
end method

method actmytype() as string
return mystring " "
end method

end class

new MyHeroeType sample("Superman")

Printy sample.actmytype

'-------------------------------------------- //
' freebasic code with cast
'
'' Type MyType
'' m_String As String
'' Declare Constructor(Byval sParam As String)
'' DECLARE OPERATOR CAST () BYREF AS STRING
'' End Type

'' Constructor MyType(Byval sParam As String)
'' m_String = sParam
'' End Constructor

'' OPERATOR MyType.CAST () BYREF AS STRING
''    OPERATOR = m_String
'' END OPERATOR

'' Dim sample As MyType = "enter man"
'' Print sample

'--------------------------------------- //
  •