'' cast example (freebasic) and oxygen translation
''
uses console
sbyte sb 'signed byte
sb=32.2
print " 32.2 "+sb ' result 32
'' freebasic
'' Print Cast( Byte, &h0080 ) '-128 ''
'' oxygen
''
sb=byte(&h0080)
print " byte ="+sb ' result: -128
'' will print 3 because the floating-point value will be converted to an Integer
'' (this Casting operator is equivalent to using CInt)
''
'' Print Cast( Integer, 3.1 ) '3
'' oxygen
''
sb=integer(3.1)
print " integer 3.1 =" + sb ' result: 3
wait
uses corewin
extern lib "User32.dll"
! CharUpper "CharUpperW" '1
! CharLower "CharLowerW" '1
! MessageBox "MessageBoxW" '1
end extern
wstring tab=wchr(9)
wstring sep
dim strx as string =" 你好吗 " '' chinese letters
mbox mid(**strx,2)
' unicode problem
" 你好吗 "
' translation: chinesisch: Nǐ hǎo ma
' english: hello how are you?
' german: "hallo wie gehts?"
' 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
' 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
'
'poba.inc
'
'-------------- //
def msgbox mbox
pro a
if not a then
call pbmain()
end if
' -- 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
' -> 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
' --> 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
Page created in 0.107 seconds with 11 queries.