Variant Data types

Started by Frank Brübach, December 14, 2024, 04:57:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Frank Brübach

Hello Charles.. little short question.. do you have ever planed to Work or build examples with Variant Data types? i suppose you weren't interested in because oxygen Had a automatically conversion of Data types? And you thought perhaps its better for Scripting languages?
Whats your opinion about this topic?

property set value ( byval value as integer ) default
 self->var.vt = VT_I4
 self->var.lVal = value
end

property set value ( byval value as double ) default
 self->var.vt = VT_R8
 self->var.dblVal = value
end

Thanks Frank 

PS: do you think the time for Basic languages are over ?

Charles Pegge

Hi Frank,

Oxygen supports variants, but as a compiler,  it is easier and more efficient to use low-level COM (IUnkwown interfaces)

An example using variants:

demos/COM/CallByName.o2bas
'16:33 09/11/2020
  '10:01 14/03/2021
  'com automation
  '
  $filename "t.exe"
  'uses rtl64
  uses  COM/COMutil
  CoInitialize null
  CreateInterfaceByName "SAPI.SpVoice" voice
  'ConnectByName "SAPI.SpVoice", voice
  '
  BSTR r
  GetByName(voice,"volume",r) : print "vol " r
  GetByName(voice,"rate",r) : print "rate " r
  CallByName( voice,"speak", "Hello World" )
  LetByName(voice,"volume",7)
  LetByName(voice,"rate",3)
  'BSTR bb={"Hello World","1"}
  'CallByName( voice,"speak", bb )
  CallByName( voice,"speak", "Hello World","1" )
  '
  'Working with variants
  ======================
  indexbase 1
  VARIANT va[2]
  va.vt[1]=VT_BSTR : va[1].bstrval="Hello Sky"
  va.vt[2]=VT_BSTR : va[2].lval=1
  CallByNameV( voice, METHOD,"speak", va,2 )
  del va.bstrval
  'print err
  ...
  voice.Release
  CoUninitialize

BASIC is way down the list of programming languages, with VisualBasic at around 4% which is less than Assembler at 5%. To be honest I would say its use is confined to elderly coders. :-\

But AI will almost certainly displace most hand-coding and disrupt the status quo of programming languages in general.

https://www.statista.com/statistics/793628/worldwide-developer-survey-most-used-languages/

Theo Gottwald

.. and therefore O2 will need Support for JSON and https://-Calls to AI Endpoints. Then it can be used for AI stuff.

Roland Stowasser

This is a nice demo. It is possible to change the parameters, so I used volume 100 and rate 0.  I noticed that my computer speaks German with a female voice, so "Introducing Oxygenbasic" sounds terrible, but "In 50 Jahren ist alles vorbei" or "Ihr Völker der Welt, schaut auf diese Stadt" sounds perfect. I wonder, if it is possible to get male voices too, or voices which can speak a different language?. 

Frank Brübach

#4
Good morning.. thanks Charles for your example and the Link.. didnt know that com Variant example thats simply good

My little example is running fine too Made a Test

' I am using a little bit added version of Variantutil.inc here ;)
'
uses variantutil1

 indexbase 1

  VARIANT va[3]
  va.vt[1]=VT_BSTR : va[1].bstrval="Hello blue Sky"
  va.vt[2]=VT_BSTR : va[2].dblval=123.456
  va.vt[3]=VT_BSTR : va[3].lval=123456

print va[1].bstrval ' "Hello blue Sky"
print va[2].dblval  ' 123.456
print va[3].lval  '123456

print "results are all ok"

About the popular programming language List I am Wondering why Python has been got so popular to BE truly I dont Like this Interpreter with all These Module stuff  and Code isnt transparent  under the Hood its c and c++

Charles Pegge

I found a short VB tutorial on changing voices:

Changing The SAPI Text To Speech Default Voice In Visual Basic. Easy VB.
Easy Visual Basic
2019



Zlatko Vid

QuoteBut AI will almost certainly displace most hand-coding and disrupt the status quo of programming languages in general.

Yeah...maybe but not very soon , currently is just a code collector/transformator there is
not real Arificial Intelligence at all.

Nicola

Hi.
I agree with you Zlatko, I'm trying out AI and indeed it's just a text selector. Quite useful for some small tasks, but for programming it often makes up nonsensical things. I tried asking it to make a simple program in O2 to create a command line for using programs like ImageMagick or ffmpeg... it often comes up with invented options. Another example, I asked it to create a 3x3 crossword puzzle matrix and it can't do it (both Copilot and ChatGPT).