Author Topic: cvl + mkl  (Read 2241 times)

0 Members and 1 Guest are viewing this topic.

Frankolinox

  • Guest
cvl + mkl
« on: July 03, 2013, 08:53:29 AM »
how to convert cvl + mkl function into oxygen?

Charles Pegge

  • Guest
Re: cvl + mkl
« Reply #1 on: July 03, 2013, 10:15:17 AM »
Hi Frank,


function cvl(string s, optional sys i) as long
if i then i-=1
long v at (i+strptr s)
return v
end function

function mkl(long v) as string
function="    "
long w at (strptr function)
w=v
end function

s=mkl 42

v=cvl s

print v


'Also useful:

sub PatchLong(string s, sys i, long v)
long w at (i-1+strptr s)
w=v
end sub

s=nuls 100
patchlong s,13,42
v=cvl s,13
print v



Frankolinox

  • Guest
Re: "cast" / cvl + mkl
« Reply #2 on: July 04, 2013, 07:18:01 AM »
thanks charles :) that works fine.

another convertion problem here with "cast" function (freebasic)

Code: [Select]
sys i,b
byte b
i=&h0080
'b=cast(byte,i) ''freebasic
b=str(i)
print b '128
print i '128
'print b,i '128, -128 freebasic

do you have a good idea for "cast" function too? thanks in advance, frank

Charles Pegge

  • Guest
Re: cvl + mkl
« Reply #3 on: July 04, 2013, 08:47:54 AM »
Hi Frank,

You don't need to cast between numbers in Oxygen, and our bytes are unsigned, so you go from 0..255.

sys i
byte b
i=&h0080
b=i
print b '128
print i '128

Frankolinox

  • Guest
Re: cvl + mkl
« Reply #4 on: July 04, 2013, 09:01:12 AM »
the problem is how to convert a "cast(a,b)" function to oxygen.

the result from freebasic was at the end 128, -128 with "b=cast(BYTE,i)", so the result for oxygen should be the same ;)

I wanted convert a freebasic example to oxygen and there's a need for it how to translate something like

Code: [Select]
...
cast(integer,x)
...

frank

Charles Pegge

  • Guest
Re: cvl + mkl
« Reply #5 on: July 04, 2013, 09:19:53 AM »
In Oxygen:

single s=4.2
long v=cast long  s
print hex(s) "    " hex(v)


'result: 4    40866666

Frankolinox

  • Guest
Re: cvl + mkl
« Reply #6 on: July 05, 2013, 12:52:57 AM »
charles, thanks, that's looking good and gives the help I wanted :-)