Recent posts

#91
Code to share / Array overlay example Translat...
Last post by Frank Brübach - April 26, 2024, 05:17:39 PM
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
#92
OxygenBasic Examples / Re: Questionmark AS command
Last post by Frank Brübach - April 26, 2024, 05:15:30 PM
Thank you Charles I Had a similar Idea with simple "d" and "p"

Have built an example too
I tried ? and ?? as sys but doesn't Work but thats Not important for me :)

Regards Frank
#93
OxygenBasic Examples / Re: Questionmark AS command
Last post by Charles Pegge - April 26, 2024, 02:43:20 PM
Hi Frank,
'?' is used as a sys casting operator.

It cannot be redefined because it is not an alpha character. But you can do this using for example, an upper ascii £ (156) :

def £ print
£ "ok"

Also, you ccould use '?' as a suffix:

def p? print
p? "ok"
#94
OxygenBasic Examples / Questionmark AS command
Last post by Frank Brübach - April 26, 2024, 01:07:48 PM
Hi Charles have a little question
How to make a ? AS Print command in oxygen?

' how to make a ? as print command?
' I assume it's an reserved character in oxygen?

' declare ?(string st) as string
' ? = print

sub questionmark(args as string)
dim i as Integer
For i=0 To Len(args)-1
'Print Chr(args[i])
Next
return Print chr(args[i]) 'chr(9)+chr(13)+ 
End Sub

questionmark("hello world")
#96
Code to share / Type example
Last post by Frank Brübach - April 25, 2024, 03:57:52 PM
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
#97
Code to share / Simple macro
Last post by Frank Brübach - April 25, 2024, 03:55:32 PM
Simple macro example

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

printy Adds("Hello my ", " Animal World")
printy Adds(2, 4) '6
#98
Code to share / Iteration expl
Last post by Frank Brübach - April 25, 2024, 03:52:43 PM
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
#99
Code to share / Enumeration example
Last post by Frank Brübach - April 25, 2024, 03:49:50 PM
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
#100
Code to share / Re: Example Intro and HalProm...
Last post by Frank Brübach - April 25, 2024, 03:47:40 PM
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