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
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
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
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
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
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
hello Frank :)
HalProment Basic is written in C# ?
can you make a 64-bit build ?
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
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
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
Simple macro example
'-- simple macro
'
macro Adds(x,y)
x + y
end macro
printy Adds("Hello my ", " Animal World")
printy Adds(2, 4) '6
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
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
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
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
'--------------------------------------- //
Here are some Array examples
' -- arrays -----
'
'-- 1)
'
pim a(20) as pro = {2,4,6,8,10,12,14,16,18,20}
a(20) = a(4) + a(6)
printy a(20) '20
'-- 2)
'
pim abc(100) as pro = {10,20,30,40,50,60,70,80,90,100}
pindex 0
printy abc[4] '50
pindex 1
printy abc[4] '40
pindex 2
printy abc[4] '30
'-- 3)
'
pim tbo(100) as pro
function abc(pro k,x)
k*=2
tbo[k]=x
end function
function abc(pro k) as pro
k*=2
return tbo[k]
end function
abc(5) = 2024
printy abc(5) ' 2024
Here an interesting zstring example
'
' zstring example: reduces text with value -1
'
dim as zstring myzText = "I love Ironman"
dim i as long
for i = 0 to len(myzText) - 1
print "zero based try: " + myzText[i]
next
for i = 1 to len(myzText)
print "one based try: " + myzText[i]
next
print "fine"
Hello 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 :)
The new Update 2 you can find in First Post at this Board
Next Update will expand and enhance Power with include Files and exe File producing
Thx, Frank
Next calculation example, printy and p?, pstring,
' simple calc with printy and p?
' and two different functions with a friendly pbmain()
'
pim a,b,c,d,e as pro
pim s,st as pstring
a=30
b=40
c=50
d=a*b
e=d*c
s= "Hello Superman "+str(d)
st= "Hello Ironman "+str(e)
printy s
p? st
function pbmain() as long
pro a=2345
pstring s="I am thor "+a
'print s
return a
end function
print pbmain() '2345
function pbmain() as long
pro a=2345
pstring s="I am thor "+a
print s
'return a
end function
pbmain() ' I am Thor 2345
[Code[
' francolinox/halProment-Basic
'-- new features: pys, p?, msgbox
'-- calc example 4
'
pim a,b,c,d,e as pro
pim z as pys
z=3
a=20
b=30
c=40
d=a*b
e=d*b
string s,st
pstring strx
strx = "powerbasic is a good basic program"
p? strx
s="Hello Batman " + str(d)
st="Hello Superman " + str(e)
print s
printy st
p? z
msgbox "hello"
Class example 2
' class test addition, division
'
class statis
method plus() as double
method average() as double
dax(100) as double
dnx as long
end class
'----------------
methods of statis
'================
method plus() as double
dim i as integer
for i = 1 to this.dnx
method += this.dax(i)
next
end method
method average() as double
method = this.plus / this.dnx 'division
'method = this.plus + this.dnx 'addition
end method
end methods
'test
dim stx as statis
stx.dax => 2,4,6,8,10,12,14,16,18,20
stx.dnx = 8
print `plus: ` str(stx.plus) ` Average: ` str stx.average ' 72, 9 '' 72,80
Here is a simple c++ example I tried to Convert and my Idea was to translate much more for next Updates
int main {
int x = 5;
int y = 6;
int sum = x + y; '
'int mult = x * y;
'cout << sum;
cout sum;
'cout mult; ' 30 ok
return 0;
}
' result 11 ok
1) Info: all new and old examples you can find in updated ZIP and rar folder in my Post #17
I couldnt changed the Text anymore in that Post #17 dont know why?
2) If you Like you can have a Look at
GitHub Frankolinox/HalProment-Basic for Download Access and Updates for next weeks and months
Next example Array redim ubound lbound (Convert from Powerbasic)
'
' -- 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
N-string example from freebasic Convert
' -- 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
Increasing number to a String Auto Convert
' -- 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
Does your Hal support recursive functions ?
Yes Here WE Go
' -- 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
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 :)
**Can you Use Pictures from the Stanley Kubrick Film "2001: A Space Odyssey" in My Software? 🤔**
I have a question regarding the use of images and names from the classic Stanley Kubrick film "2001: A Space Odyssey" in my software. Specifically, I want to know if I can use single pictures from the movie and the name "HAL" without running into legal issues.
Here is the answer:### Copyright on Images 📸
1. **Images from the Film**: - The film "2001: A Space Odyssey" is protected by copyright law. This includes any still images taken from the movie. You cannot legally use these images without permission from the copyright holder.
- If you want to use images from the film, you would need to seek permission or license them from the rights holder, which is often the studio that produced the film (MGM or Warner Bros).
### Trademark on Names 🏷�
2. **Use of the Name "HAL"**: - The name "HAL" from the film is likely trademarked. Using it in your software could lead to trademark infringement issues, especially if it is used in a way that could cause confusion with the original character or brand.
- To use the name "HAL" legally, you would need to check the trademark status and possibly seek permission from the trademark holder.
### Alternatives 💡
- **Public Domain or Licensed Images**: You could look for images that are in the public domain or available under a suitable license (such as Creative Commons) that explicitly allows commercial use.
- **Generic Names**: Instead of "HAL," you could create an original name for your software to avoid any trademark issues.
### Conclusion ✅
You should not use images from "2001: A Space Odyssey" or the name "HAL" in your software without proper licensing or permission. For a safe and legally sound approach, consider using public domain images and original names. If in doubt, consulting with a legal professional specialized in intellectual property law is recommended.
---
Hope this helps! 😊
Thanks for Info yes you are right I will Change it.. I am on Holiday for some days, frank
PS Look at this :)
Movie: A space odyssee by Stanley Kubrick (1968)
Licensing
This work is in the public domain in the United States because it was published in the United States between 1929 and 1977, inclusive, without a copyright notice. For further explanation, see Commons:Hirtle chart as well as a detailed definition of "publication" for public art. Note that it may still be copyrighted in jurisdictions that do not apply the rule of the shorter term for US works (depending on the date of the author's death), such as Canada (50 p.m.a.), Mainland China (50 p.m.a., not Hong Kong or Macao), Germany (70 p.m.a.), Mexico (100 p.m.a.), Switzerland (70 p.m.a.), and other countries with individual treaties.
Hi Frank
I am asking about source code which HalPro use
because is based on BInd32 as far as i remember
so is it open surce or not ?
@Frank Brübach As a general hint: "American Culture" is never free, is generally only for commercial use. Thats the difference to for example german, or european culture.
In USA there is no "free lunch".
Therefore keeping away from american stars, idiots, logos, brands and generally anything from USA that is promoted, helps to save costs.
QuoteThis work is in the public domain in the United States because it was published in the United States between 1929 and 1977, inclusive, without a copyright notice.
If someone has posted that on the internet, it must be true, right? :)
(source needed)
This movie was copyrighted in the US by Metro-Goldwyn-Mayer, Inc. in April, 3, 1968 (copyright number LP36136) and, of course, is not in the public domain.
"In the United States, motion pictures published before 1978 are copyrighted for 95 years. All motion pictures made and exhibited before 1929 are indisputably in the public domain in the United States. This date will move forward one year, every year, meaning that films released in 1929 will enter the public domain on New Year's Day 2025, films from 1930 on New Year's Day 2026, and so on."
https://en.wikipedia.org/wiki/Public_domain_film#:~:text=All%20motion%20pictures%20made%20and,Day%202026%2C%20and%20so%20on.
Besides, Turner Entertainment Company, which purchased Metro-Goldwyn-Mayer, Inc. in 1986, renevewd the copyright in 1996.
2001: a space odyssey. By Metro-Goldwyn-Mayer, Inc.
Type of Work: Motion Picture
Registration Number / Date: RE0000731536 / 1996-08-20
Renewal registration for: LP0000036136 / 1968-04-03
Title: 2001: a space odyssey. By Metro-Goldwyn-Mayer, Inc.
Copyright Claimant: Turner Entertainment Company (PWH)
https://cocatalog.loc.gov/cgi-bin/Pwebrecon.cgi?v1=22&ti=1,22&Search%5FArg=2001%3A%20a%20space%20odyssey&Search%5FCode=TALL&CNT=25&PID=NsABRvjaJGlFSV90El_gfoBzX44F&SEQ=20240517112215&SID=2
QuoteThis work is in the public domain in the United States because it was published in the United States between 1929 and 1977, inclusive, without a copyright notice.
I have found the source:
https://en.m.wikipedia.org/wiki/File:2001_A_Space_Odyssey_(1968)_-_Trailer.webm
It is not the movie that is in the public domain, but a trailer of 3 minutes, 32 seconds.
OK I See noticed this link for Infos
https://en.m.wikipedia.org/wiki/File:2001_A_Space_Odyssey_(1968)_-_Trailer.webm#:~:text=This%20work%20is%20in%20the,inclusive%2C%20without%20a%20copyright%20notice.
Perhaps I must contact directly turner or Christiane Kubrick :)
Many thanks Theo and Jose for Infos and Feedback.. but I have Not in my mind to Change the Name of my Basic Compiler until or Else a Person or company will get harm.. in musician Branche there are a Lot of Songs and Bands with equal names
Thx, Frank
I don't think the name 'Hal' falls within the scope of Copyright law, or even Trade-Mark law, since it is a common name, and not associated with any brand of computer technology. In any case, it is 'HalPromide' which is a unique name for a computer product.
Here are some names which might be problematic :)
ArmBasic
IBMBasic
YamahaBasic
TeslaBasic (might be ok, thanks to Nicola Tesla)
PorscheBasic
CocaColaBasic
Frank
Don't wast time on copyrights ..and better answer on my question
if is not a problem ..in
copyright maybe
QuoteI am asking about source code which HalPro use
because is based on BInd32 as far as i remember
so is it open surce or not ?
Thanks Charles Sounds good for me too
I have changed Intro Image for my next Update with mother earth
@zlatko
Read my Post #7 I am Not programming with Powerbasic anymore. No Open source..
Regards, Frank
QuoteHello 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
and what a heck that means?
so ..no open source ...sure ..but how we to know that Hal is written in
Oxygen basic ....i think that is not.
I don't have to prove anything and actually it doesn't matter what you think. Almost all of my examples also run under o2bas
I have helped you with oxygen examples for some times and nothing from your Site No thanks so you are an ungrateful man for me.. Here its the Last time I reply to you
Hello all Here is an Update 3 of halProment Basic with deleted Image of Intro Scene and replaced it with mother earth Image ;)
All examples you can find Here in *.rar folder and new halpromide24 Editor
Bufferstring example o2 Convert to halProment
'----------------------------
'APPENDING INTO STRING BUFFER
'============================
' -- original bufferstring (demos/basics) oxygen example convert to halProment
' -- no changes needed ;)
'
dim i,j as long
dim s,t as string
j=1
s=space 500
for i=1 to 10
t=str(i) chr(9) chr(i+64) chr(13) chr(10)
mid (s,j)=t
j+=len t
next
print "result 1 oxygen"
print left s,j-1
' oxygen ends
'-------------------------------------------- //
' halproment style alternative 2x
pim i,j as pro
pim s,t as pstring
j=1
s=space 500
for i=1 to 10
t=str(i) chr(9) chr(i+64) chr(13) chr(10)
mid (s,j)=t
j+=len t
next
printy "result 2 halProment"
printy left s,j-1
printy "result 3 halProment"
p? left s,j-1
' halproment style alternative ends
QuoteI don't have to prove anything and actually it doesn't matter what you think.
First of all..i am not asking you about prove
and good to know that i know now what is you attitude...
You helped me...really ? ha ha
ok i don't care ;D
Byte Array example
' -- byte array example
'
pim strsrc as pstring
strsrc = "Hello, Animal World!"
Dim byteArray() as byte at strptr(strsrc)
pim i,j as pro
pim s,t as pstring
j=1
s=space 600
for i=1 to 20
t=chr(9)+str(byteArray[i]) ": " + chr(byteArray[i])
mid (s,j)=t
j+=len t
next
p? left s,j
[/]
Array examples how to reduce a String Text
' array reducing for a string
'
pindex 0
Dim txt() as zstring = "Hello World " + Chr(0)
dim i as integer
For i = 0 to Len(txt)-2 ''Len(txt)-1 if pindex is not active
p? txt(i) + Chr(txt(i))
Next
' output: hello world ello world llo world lo world o world
' output: world orld rld ld d
Window winapi GUI (SDK)
' -- windows gui test, halProment, 19-05-2024 --
'
take diverprom
'--------------------------------------------------------------------
Function WinMain(sys inst, prevInst, asciiz*cmdline, sys show) as pro
'====================================================================
WndClass wc
MSG wm
sys hwnd, wwd, wht, wtx, wty, tax
with wc
.style = CS_HREDRAW or CS_VREDRAW
.lpfnWndProc = @WndProc
.cbClsExtra =0
.cbWndExtra =0
.hInstance =inst
.hIcon=LoadIcon 0, IDI_APPLICATION
.hCursor=LoadCursor 0,IDC_ARROW
.hbrBackground = GetStockObject WHITE_BRUSH
.lpszMenuName = null
.lpszClassName = strptr "Demo"
end with
sys r=RegisterClass (@wc)
Wwd = 520 : Wht = 400
Tax = GetSystemMetrics SM_CXSCREEN
Wtx = (Tax - Wwd) /2
Tax = GetSystemMetrics SM_CYSCREEN
Wty = (Tax - Wht) /2
'
hwnd = CreateWindowEx 0,wc.lpszClassName,"HalProment Basic",WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,0,0,inst,0
if not hwnd
mbox "Unable to create window"
exit function
end if
'
ShowWindow hwnd,SW_SHOW
UpdateWindow hwnd
'
sys bRet
'
do while bRet := GetMessage (@wm, 0, 0, 0)
if bRet = -1 then
'show an error message
else
TranslateMessage @wm
DispatchMessage @wm
end if
wend
end Function
dim as rect crect
'------------------------------------------------------------------
function WndProc (pro hWnd, wMsg, wParam, lparam ) as pro callback
'==================================================================
static as pro hdc
static as pstring txt
static as PaintStruct Paintst
'==========
select wMsg
'==========
'--------------
case WM_CREATE
'=============
GetClientRect hWnd,cRect
'--------------
case WM_DESTROY
'===============
PostQuitMessage 0
'------------
case WM_PAINT
'============
GetClientRect hWnd, cRect
hDC=BeginPaint hWnd, Paintst
SetBkColor hdc,black 'yellow
SetTextColor hdc,green 'red
DrawText hDC,"Hello Animal World!",-1,cRect,%DT_SINGLELINE or %DT_CENTER or %DT_VCENTER
EndPaint hWnd,Paintst
function = 1
'--------------
case WM_KEYDOWN
'==============
'============
Select wParam
'============
Case 27 : SendMessage hwnd, WM_CLOSE, 0, 0 'ESCAPE
End Select
'--------
case else
'========
function=DefWindowProc hWnd,wMsg,wParam,lParam
end select
end function
' WinMain inst,0,cmdline,SW_NORMAL '' both lines are working
WinMain 1,0,1,SW_NORMAL
Finally the big step to 64 Bit architecture
Thanks Charles for His great rtl32.inc and rtl64.inc Files :-)
All examples you can find in *.rar folder below
If you have any questions please ask thx, frank
'' -- halProment Basic 64 bit test, 26-5-24, 29-05-24, by frank bruebch
'' -- you must compile this example with menu compile/quickrun produces an exe file
''
$ FileName "test64-2.exe"
#include "$\inc\pro64.inc" ''
Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Sys
byte val1
byte val2
int result
val1=4
val2=6 '
'mov eax,val1
mov eax,val2 ''multiply (or add) eax by ebx "
'mul val1 'ebx
add eax,5 '' here add 5
mov result,eax
zstring tit[]="HalProment Basic 64 bit"
zstring msg[]="Hello dear Animal World! " + str(result)
'' halProment Basic 64 bit
''
sub rsp,40h
mov r9, 0
lea r8, tit
lea rdx, msg
mov rcx, 0
call messagebox
add rsp, 40h
''
''
'' output: Hello dear Animal World! 11 (add) ' 24 (multiply)
''
#ifdef mode64bit
#print "Producing 64-bit code output"
print "Producing 64-bit code output"
#else
#print "Producing 32-bit code output"
#endif
'' result: "Producing 64-bit code output" ' all ok :-)
PS you can Download the latest Update under GitHub too
Here is a little sizeof example
Print SizeOf(Byte) ' returns 1
Type mybar
a As Integer '4
b as float '4
c as long '4
d As Double '8
e as ulong '4
f as short '2
g as byte '1
End Type
dim myfoo as mybar
print SizeOf(myfoo) ' returns 32
I would luv the compiler to be a 64bit one.
It looks similar to O2, can I port O2 codes into Frank Basic ?
Thanxx a lot
Hello Chris thx for Feedback..
yes nearly 90 / 92 percent at the Moment are compatible with o2 Code.
Whats the meaning of "luv"? Lift and Transport?
Regards Frank
Hi Frank
What are the challenges to convert from PB to FrankBasic ? Do you have a guide to convert from Powerbasic
to FrankBasic ?
Does FrankBasic has an IDE ?
Thank you
Regards
Karen
Hello Karen :)
Its Not such a big step a Lot of commands and Syntax are equal to Powerbasic and freebasic.
The Name of my Compiler is "halProment Basic" , the Ide calls halPromide24.
You can Download the *.rar File some Posts before (post #48) there are a Lot of examples for Testing .. you can create Exe File too with Last update4 and there is a 64bit DLL too..
You will find a similar Powerbasic example too in my example folder ;)
All Work in Progress. If you have more questions please ask Here. Its all in Beta Version, but advanced..
Thanks, Frank
PS you can Download via GitHub Last Update 4 too
@karen
PS a guide doesn't exist yet at this Moment .. its a Hobby Project and If there's more time I will build such a Help File..
Hello all.. much more to come with a new Update with my Last Post later
How to create an EXE File?
' --> atestcalc 2 example
' --> create an Exe file with halProment
' --> menu/compile/Run compiling 32 bit
'
#fily "atestcal.exe"
dim s,st as string
dim a,b,c,d,e as long
a=10
b=20
c=30
d=a*b
e=d*c
s= "hello batman " + str(d)
st= "hello superman " + str(e)
print s ' result 200
print st ' result 6000
'-------------------------- //
'
pstring s1,st1
pro a,b,c,d,e ' pim as a,b,c,d,e as long
a=10
b=20
c=30
d=a*b
e=d*c
s1 = "hello batman1 " + str(d)
st1= "hello superman1 " + str(e)
print s1 ' result 200
print st1 ' result 6000
CByte example for riunding Numbers and Auto converting Strings
' -> cbyte example, rounded numbers or converting strings
' halProment
'
'dim cb as cbyte
cbyte cb
cb=45.2 ' 45
print cb
cb=72.6
print cb ' 73
cb="-72"
print cb ' -72
cb="-122.5"
print cb ' -123
cb=255
print cb '-1
cb=260
print cb '4
A Byte Array examples
' -- byte array example
'
pim strsrc as pstring
strsrc = "Hello, Animal World!"
Dim byteArray() as byte at strptr(strsrc)
pim i,j as pro
pim s,t as pstring
j=1
s=space 600
for i=1 to 20
t=chr(9)+str(byteArray[i]) ": " + chr(byteArray[i])
mid (s,j)=t
j+=len t
next
p? left s,j
Powerbasic Looks a Like example with inc File
A new Update you can find below with all examples for Testing
If you have question about halProment or the halPromide24 (IDE) please ask :)
Regards, Frank
' poba looks like calculation, halProment, 2-6-24
'
''#COMPILE EXE
#DIMALL
include once "poba.inc"
FUNCTION PBMAIN() AS LONG
LOCAL a,b,c AS LONG
a=20
b=40
c=a*b
MSGBOX "calculation test: "+str(c) ' result 800
END FUNCTION
Include File
'
'poba.inc
'
'-------------- //
def msgbox mbox
pro a
if not a then
call pbmain()
end if
Array Reducing a Text for a String
' array reducing text for a string
'
pindex 0
Dim txt() as zstring = "Hello World " + Chr(0)
dim i as integer
For i = 0 to Len(txt)-2 ''Len(txt)-1 if pindex is not active
p? txt(i) + Chr(txt(i))
Next
' output: hello world ello world llo world lo world o world
' output: world orld rld ld d
Hello all
I am working at a new update of halProment
Next to See will be a simple OpenGL example and a new gui example Double Buffer Just for Testing
Pics below
OK Here four new example they are running all with latest Update
First example : Timer Array Speed example
'
' speed timer example with array redim
'
Type SYSTEMTIME
word wYear
word wMonth
word wDayOfWeek
word wDay
word wHour
word wMinute
word wSecond
word wMilliseconds
End Type
Declare GetSystemTime LIB "KERNEL32.DLL" ( SYSTEMTIME *lpSystemTime )
Declare GetLocalTime Lib "kernel32.dll" ( ByRef lpSystemTime As SYSTEMTIME )
function TimeLapsesMis(SYSTEMTIME *ti1,*ti2) as long
=====================================================
'<60 second timer
long tad = ti2.wMilliSeconds-ti1.wMilliseconds+
((ti2.wSecond-ti1.wSecond)*1000)+
((ti2.wMinute-ti1.wMinute)*60000)+
((ti2.wHour-ti1.wHour)*3600000)+
((ti2.wDayOfWeek-ti1.wDayOfWeek)*86400000)
'
'end of week crossing
if tad<0 then tad+=604800000
return tad
end function
'---Variables declaration
dim MaxCount as long
maxCount = 1e7 '10 million
'maxCount = 10000000
SYSTEMTIME thisTime0
SYSTEMTIME thisTime1
'---Start time
GetSystemTime thisTime0
'---Dimension the array
redim pro MyArray(maxcount)
dim count as long
'---Fill the array
for Count = lbound(MyArray) to ubound(MyArray)
MyArray(Count) = Count*Count '^2
next
'---End time
GetSystemTime thisTime1
'format 'str better here
print "total time to fill an EXT array of " + MaxCount + " elements: " + str(TimeLapsesMis(thisTime0,thisTime1), "###") + " msecs"
Here three new functions Like extract, retain, remain for String manipulations
Extract example
' -- extract function go, halProment, 6-6-24
'
Function Extract( ByRef nStart as Integer, _
ByRef sMainString As String, _
ByRef sMatchPattern As String) As String
Dim nLenMain As Integer = Len(sMainString)
Dim i As Integer
If (nStart = 0) Or (nStart > nLenMain) Then Return ""
If nStart < 0 Then nStart = nLenMain + nStart + 1
i = Instr(nStart, sMainString, sMatchPattern)
If i Then
Function = Mid(sMainString, nStart, i-nStart )
Else
Function = Mid(sMainString, nStart)
End If
End Function
dim a as string
dim i as long
i=1
a = Extract(1,"abacadabra","cad")
print a ' aba
Remain example
' -- remain function go, halProment, 6-6-24
'
Function Remain(ByRef nStart As Integer, _
ByRef sMainString As String, _
ByRef sMatchPattern As String) As String
Dim nLenMain As Integer = Len(sMainString)
Dim i As Integer
If nStart = 0 Or nStart > nLenMain Then Return ""
If nStart < 0 Then nStart = nLenMain + nStart + 1
i = Instr(nStart, sMainString, sMatchPattern)
If i Then
Function = Mid(sMainString,i+Len(sMatchPattern))
Else
Function = ""
End If
End Function
dim a as string
dim i as integer
i=1
a = Remain(i,"yes, I have two big porsche matchbox cars in my garage", ",")
print a ' result: I have two big porsche matchbox cars in my garage
'print "ok"
If you have questions to this and other examples please ask thx, Frank
Retain example
' retain
Function my_RetainAny( ByRef sMainString As String, _
ByRef sMatchPattern As String) As String
Dim nLenMain As Integer = Len(sMainString)
Dim nLenMatch As Integer = Len(sMatchPattern)
If nLenMatch = 0 Then Return ""
Dim y As Integer = 1
Dim i As Integer = 1
Dim sChar As String
Dim s As String
For y = 1 To Len(sMainString)
sChar = Mid(sMainString, y, 1)
i = Instr( sMatchPattern, sChar )
If i > 0 Then s = s + sChar
Next
Return s
End Function
string a,b,c
a = "<ts>y2334958690xdu7v<ab;db;d>y2334958690xdu7v</ts>"
b = my_RetainAny(a,"<;/ts>")
print b
c = my_RetainAny(a,"123456789") ' any
print c
Good morning Here I add Last Not least a Tally function I have forgotten to send Yesterday
'
' tally example, halProment, 06-06-2024, go
'
' Declare the Tally function
' DECLARE FUNCTION Tally(search AS STRING, data AS STRING) AS INTEGER
' Define the Tally function
FUNCTION Tally(string search, datas ) AS INTEGER
DIM count AS INTEGER = 0 ' Initialize the counter
DIM i AS INTEGER ' Loop variable
' Loop through each occurrence of the delimiter in the data string
FOR i = 1 TO LEN(datas) STEP LEN(search)
' If the substring at this position is equal to the search string, increment the counter
IF MID(datas, i, LEN(search)) = search THEN
count = count + 1
END IF
NEXT i
' Return the count
RETURN count
END FUNCTION
' Example usage
DIM datas AS STRING = "BJF1, BJF2, BJF1, BJF3, BJF1, BJF4"
PRINT "The string 'BJF1' occurs " + STR(Tally("BJF1", datas)) + " times in the data."
' result 3 times