Recent posts

#91
OxygenBasic / Re: Pointers and type casting
Last post by Zlatko Vid - March 25, 2024, 11:30:03 PM
Thanks Charles

but why this one work

sys *p = @n

i just tried ..i don't know that work or
simply i expected that not work ...
because of dereferencing  symbol *

of course this looks better:
f2 = (float*) p

#92
OxygenBasic / Re: Pointers and type casting
Last post by Charles Pegge - March 25, 2024, 10:31:11 PM
Hi Aurel,

This shows the o2 syntax alternatives for casting pointers:

'casting pointers
=================
float n = 3.14
sys p = @n
float f2
f2 = (float*) p
print str(f2,2)
print str((float*)p,2)
print str(cast(float*)p,2)
print str(cast float*p,2)

#93
OxygenBasic / Pointers and type casting
Last post by Zlatko Vid - March 25, 2024, 09:38:45 PM
Hi Charles ..All  :)

is this only way to cast float variable in o2 ?
using in this case dereferece * ...

float n
'INT i at strptr s  ' integer pointer cast string s
n = 3.14
sys *p = @n
float f2 = (float)p

print f2

I am looking in all examples ...functionPointers 1 and 2
and not understand it well
like in old EBasic where is used :

print *<float>p

is that syntax even possible in o2
if you ask me i am fine with (float)

but above looking more fancy ...?

#94
OxygenBasic / Re: dll for HTTPS that uses th...
Last post by Charles Pegge - March 25, 2024, 06:35:54 PM
At around 11 Centigrade I can protect myself from the chill very effectively, except for my fingertips. There might be a market for heated keyboards..

I see that PureBasic is cross-platform and has around 1600 functions. I looks like a good product. Are there any down-sides to using PureBasic, Theo?

The other PB has rather ominously closed its web site for maintenance over the last few days.

#95
OxygenBasic Examples / Re: Old o2 example "Compile" ?
Last post by Charles Pegge - March 25, 2024, 05:08:13 PM
It must be very old code. It looks like secondary compiling which o2 no longer supports. You can see the source code of the current compiler in \tools\co2.o2bas
#96
OxygenBasic Examples / Old o2 example "Compile" ?
Last post by Frank Brübach - March 25, 2024, 04:31:53 PM
Hello all

Found this old oxygen example there is a Compiler / uncompile command how I can fix this example?


  ' what does it mean this command "compile" ? = o2_basic(s) ?

extern lib "oxygen.dll"
    declare function o2_basic(byref s as asciiz) as long
    declare function o2_exec (byval p as long) as long
    declare function o2_errno() as long
    declare function o2_error() as asciiz ptr
  end extern
  '
  dim qu as string
  dim cr as string
  dim src as string
  qu=chr(34)
  cr=chr(13)+chr(10)
  src="print " + qu+"Hello Oxygen"+qu+cr
  print src
  '
  o2_basic(src)
  '
  if o2_errno()<>0
    print o2_error()
  else
    o2_exec(0)
  end if
  end

  ' what is uncompile ?

  '--------------------------------------------------------------------------
  function evaluate (s as string, byval b as long, byval e as long) as string
  '==========================================================================
  '
  double x,y,z
  long a,i,p=1
  string v,u,tab,cr,er as string
  '
  cr=chr(13) chr(10) : tab=chr 9
  v=nuls 4000
  mid v,p,s+cr+cr
  p+=4+len s
  '
  a=compile s ' what is compile ?'
  'a=o2_basic s ' what is compile ?
  'o2_basic
  er=error
  if er then print `runtime error: `  er : uncompile a : exit function
  for i=b to e
    x=i
    call a
    u=str(x) tab str(y) cr
    mid v,p,u : p+=len u
  next
  '
  function=left v,p-1
  'uncompile a
  end function
 
  print evaluate `y=x*x*x`,1,10
  print evaluate `y=sqrt x`,1,9
 

Thanks, frank
#97
OxygenBasic / Re: dll for HTTPS that uses th...
Last post by Eduardo Jorge - March 25, 2024, 12:22:18 AM
hi, charles, I'm glad you're okay,
but wow, I don't think I could handle this kind of cold,
I'm from Rio de Janeiro, Brazil, and it's been very hot here and now that it's cooled down and there are constant storm warnings, the The cold weather it's getting here would probably be like summer for you, well, extremes are always bad.

I would only use it until I had some money left to build a new PC, although I only use the PC to use spreadsheets and visit some internet pages since Firefox and Chrome still work,
There wouldn't even be a need to spend money on it since it's more of a hobby so it's last on the planning list, the most ironic thing is that just this month I've already assembled and configured 2 gaming PCs for other people
#98
OxygenBasic / Re: dll for HTTPS that uses th...
Last post by Charles Pegge - March 24, 2024, 08:48:57 PM
I'm okay thanks, Eduardo, but it's cold up here. I wear the winter clothing of a reindeer herder :)

You can run dlls in the same folder as your executable, but you may have to specify the address to be sure they are accessed peferentially.

I found this article discussing Wininet.dll and some of its dependencies.


Under the Hood: WinINet

https://techcommunity.microsoft.com/t5/ask-the-performance-team/under-the-hood-wininet/ba-p/372499

2007 / 2019

#99
OxygenBasic / Re: dll for HTTPS that uses th...
Last post by Eduardo Jorge - March 24, 2024, 06:08:41 PM
Hi Charles, how are you?

Unfortunately, Win7 doesn't have TLS 1.3, only up to 1.2.

Is it possible to get the wininet.dll or winhttp.dll from Win10 and put it in a separate folder to use for O2? How would it work if wininet.dll was in a separate folder?

I've already got them, but I'm going to try to replace the ones in the "C:\Windows\System32" folder. I can't access them to change them in Windows itself, but I also don't know if there will be any errors after changing them.

Theo Gottwald, from what I saw  Purebasic also uses the operating system API to connect to the internet, so it works the same as O2 in that regard. It would only be valid if there was a library to be incorporated into the code to make it independent, like the more up-to-date curl or winhttp.h.
#100
OxygenBasic / Re: dll for HTTPS that uses th...
Last post by Charles Pegge - March 24, 2024, 04:32:05 PM

Hello Eduardo,

A very simple example using wininet.dll to view the raw content of forum.it-berater.org/index.php via https.

I use Windows 11. I don't know if Windows 7 supports the TLS protocol.

extern lib "wininet.dll"

! InternetOpenA
! InternetOpenUrlA
! InternetCloseHandle
! InternetReadFile

end extern

string buf=nuls 0x20000 '128k
string tbuf
'string url="http://forum.it-berater.org/index.php"
string url="https://forum.it-berater.org/index.php"
int cbytes
sys hInternet
sys hFile
int c
hInternet = InternetOpenA( "o2demo",0,0,0,0 )
hFile = InternetOpenUrlA( hInternet,url,0,0,0,0 )
do
  cbytes=0
  InternetReadFile( hFile,buf,len(buf),@cbytes )
  if cbytes
    tbuf+=left(buf,cbytes)
    c++
  else
    exit do
  endif
loop
InternetCloseHandle( hFile )
InternetCloseHandle( hInternet )
'print tbuf
putfile( "t.txt",tbuf )
'print c 'count loops


NOTES:
======

'https://docs.microsoft.com/en-us/windows/win32/api/wininet/nf-wininet-internetopena
'https://docs.microsoft.com/en-us/cpp/mfc/wininet-basics?view=vs-2019#_core_create_a_very_simple_browser


/*
% INTERNET_OPEN_TYPE_DIRECT 1
% INTERNET_FLAG_ASYNC 0x10000000
*/

/*
extern lib "wininet.dll"

sys InternetOpenA(
  LPCSTR lpszAgent,
  DWORD  dwAccessType,
  LPCSTR lpszProxy,
  LPCSTR lpszProxyBypass,
  DWORD  dwFlags
);

BOOLAPI InternetCloseHandle(
  HINTERNET hInternet
);

BOOLAPI InternetCanonicalizeUrlA(
  LPCSTR  lpszUrl,
  LPSTR   lpszBuffer,
  LPDWORD lpdwBufferLength,
  DWORD   dwFlags
);
sys InternetOpenUrlA(
  HINTERNET hInternet,
  LPCSTR    lpszUrl,
  LPCSTR    lpszHeaders,
  DWORD     dwHeadersLength,
  DWORD     dwFlags,
  DWORD_PTR dwContext
);

BOOLAPI InternetReadFile(
  HINTERNET hFile,
  LPVOID    lpBuffer,
  DWORD     dwNumberOfBytesToRead,
  LPDWORD   lpdwNumberOfBytesRead
);

BOOLAPI InternetFindNextFileA(
  HINTERNET hFind,
  LPVOID    lpvFindData
);

*/

'#include <afxinet.h>

/*
void DisplayPage(LPCTSTR pszURL)
{
   CInternetSession session(_T("My Session"));
   CStdioFile* pFile = NULL;
   CHAR szBuff[1024];
   //use a URL and print a Web page to the console
   pFile = session.OpenURL(pszURL);
   while (pFile->Read(szBuff, 1024) > 0)
   {
      printf_s("%1023s", szBuff);
   }
   delete pFile;
   session.Close();
}
*/