Recent posts

#1
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Theo Gottwald - Yesterday at 09:27:20 PM
Assuredly shun the Python's lure, employ the AI, sans Python's core. 🐍✖️🤖✨
#Goethe #Poetry #AI #Technology #NoPython

See:
Smart Package Robot

TwitterBar_02.png
#2
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Frank Brübach - Yesterday at 07:22:07 PM
I dont Trust this ai at all... Written in Python Elon Musk and Microsoft has fully Control and you will get only Code snippets by Other languages concerning programming structures
#3
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Charles Pegge - Yesterday at 07:00:04 PM
Hi Theo,

I don't think its using Oxygen, but it might be quite good for outlining programs and algorithms. As they say: the devil is in the detail.
#4
OxygenBasic Examples / Re: OpenGL Slider + vector dat...
Last post by Frank Brübach - Yesterday at 06:19:35 PM
Very good many thanks Charles :)

I have scaled the sliders in my Second example without Problems with

   for i=1 to ordn : cb[i].sc=1/2 : next '

Its possible to make a String Label for the sliderboxes? Can I do IT with GetWordArea or simple gprint?

Best regards Frank
#5
OxygenBasic Examples / Re: OpenGL Slider + vector dat...
Last post by Charles Pegge - Yesterday at 03:51:59 PM
Hi Frank, This fixes your slider scaling problem on the first example:

A small alteration in the PanelA object, which is now included in the source.

        drag(dx,dy,1.0/sc)

Then you can set the scale here:

    'set scale
    for i=1 to ordn : cb[i].sc=2.5 : next

'-------- experiment to combine triangle data with slider overlapped
  '-------- oxygenbasic, by frank brübach, 27-11-2023
  '
  #compact
 '%filename "t.exe"
 'uses RTL64
  % Title "Triangle Data:  Move points with mouse and arrow keys etc"

 '% WindowStyle WS_OVERLAPPEDWINDOW
 '% Animated
 '% ScaleUp
  % PlaceCentral
  % AnchorCentral

  % shaders

  uses consoleG
 'uses glo2/geoplanar
  'uses ControlPanels


  uses controls
  ===================
  class ControlPanelA
  ===================
  float  x,y,z
  int    id
  float  xx,yy,zz
  float  dx,dy,dz
  float  sc
  int    lock
  int    t1,t2
  int    f1,f2
  =================
  sliders      c[4]
  lightbuttons l[4]

  method act(optional int n)
  indexbase 1
  if id=0
    f1=0 'cube
    f2=0 'pent
    --------------------------------------------------------------------------
    'ctrl   x    y   z     sc    shm shb tex id  lk  lbl
    --------------------------------------------------------------------------
    c[1]=>-.40,-.00, .00,  0.10, f1, 00, t1, 10, 1, "slider"
    c[2]=>-.30,-.00, .00 , 0.10, f2, 00, t1, 20, 1, "slider"
    c[3]=>-.20,-.00, .00 , 0.10, f2, 00, t1, 30, 1, "slider"
    c[4]=>-.10,-.00, .00 , 0.10, f2, 00, t1, 40, 1, "slider"
    -------------------------------------------------------------------------
    l[1]=>-.40, .15, .00,  0.02, f1, 00, t1, 50, 1, "light button"
    l[2]=>-.30, .15, .00 , 0.02, f2, 00, t1, 60, 1, "light button"
    l[3]=>-.20, .15, .00 , 0.02, f2, 00, t1, 70, 1, "light button"
    l[4]=>-.10, .15, .00 , 0.02, f2, 00, t1, 80, 1, "light button"
    --------------------------------------------------------------------------
    id=1+n
    int i
    for i=1 to 4
      c[i].id+=n
      l[i].id+=n
    next
  end if
  '
  glpushmatrix
  gltranslatef  x,y,z
  '
  gltranslatef -.25,.0,-.0005
  if sc then glscalef sc,sc,1.0
  if pick
    PickLabel id
  else
    QuadShadow .20,.20,.005,.5
    glcolor3f     .60,.50,.60 'fix alpha bug
    glcolor4f     .60,.50,.60,0.50 'box
  endif
  QuadTex       .20,.20,.0.01
  gltranslatef  .25,.0,-.0
  '
  if bleft
    if picked=id
      if not lock
        drag(dx,dy,1.0/sc)
        x=xx+dx : y=yy+dy
      end if
    end if
  else
    xx=x : yy=y : zz=z 'ANCHOR
  end if
  '
  'render
  '
  int i,oi1,oi2
  for i=1 to 4
    c[i].act(1,i,oi1)
    l[i].act(1,i,oi2)
  next
  glpopmatrix
  '
  'show data
  '
  'glDisable GL_TEXTURE_2D
  glDisable GL_LIGHTING
  '
  glPushMatrix
  glLoadIdentity
  if pick
    PickLabel 0
  endif
  gltranslatef -.5,.35,-1.0
  float w,h
  glscalef     .05,.05,.01
  GetWordArea  "Control:",w,h
  if pick
    PutBoxArea   w,h
  else
    glColor3f    .99,.99,.00
    gprint       "Control: "
    glColor3f    .99,.99,.99
    gprint    str(picked)
    if oi1+oi2
      gprint "   "
      if oi1 then gprint str((1.0+c[oi1].vy)*50 , 0)
      if oi2 then gprint str (l[oi2].lit)
    end if
  end if
  glPopMatrix
  end method
  '
  method destructor()
  ===================
  'del this.label
  'sliders      c[4]
  'lightbuttons l[4]
  int i
  for i=1 to 4
    c[i].destructor
  next
  for i=1 to 4
    l[i].destructor
  next
  end method
  '
  end class

  '#recordof ControlPanelA



  'Keys: Esc, arrow-keys, n,m, F4

  'uses OpenglSceneFrame
  'uses ControlPanels

  indexbase 1
  sys       texn[16]
  sys       GdiplusToken
  float     ang1
  sys       cube,pent


  sub initialize(sys hWnd)
  ========================
  '
  GDIplus 1
  '
  cube=CompileList : CubeForm    : glEndList
  end sub


  sub Release(sys hwnd)
  =====================
  glDeleteLists    cube,1
  glDeleteLists    pent,1
  Gdiplus 0
  end sub


  BeginScript

  procedure main() 'triangle-data example
  ================

  static single ra,ri,angi1=.5
  static sys    initscene
  sys hwnd
  '
  '
'--------------------------------------------------- //
  'WaitForEvent '0 off 1 on (default on)
  static quad t1,t2

  if opening 'FIRST CALL ONLY
    timemark t1
    'picked=100
    'mbox "helo"
  end if
  '
  if closing 'FINAL CALL BEFORE SHUTDOWN
    'mbox "Bye!"
    exit sub
  end if
  cls
  shading
  UserMovement mu,1100,3 'symbol identity, count
  if opening
    mu[1].x= 0
    mu[1].y= 5
    mu[2].x=-5
    mu[2].y=-5
    mu[3].x= 5
    mu[3].y=-5
  endif
  scale 1
  picklabel 0
  int i
  for i=1 to 3
    pushstate
    mu[i].act
    color 1,.9,0,1
    scale 0.4
    go sphere
    popstate
  next
  float xa,xb,xc,ya,yb,yc
  xa=mu[1].x : ya=mu[1].y
  xb=mu[2].x : yb=mu[2].y
  xc=mu[3].x : yc=mu[3].y
  '
  'MOUSE DRAG ADJUSTMENT
  select picked
    case 1100 : xa+=mu[1].d.x : ya+=mu[1].d.y
    case 1200 : xb+=mu[2].d.x : yb+=mu[2].d.y
    case 1300 : xc+=mu[3].d.x : yc+=mu[3].d.y
  end select
  flat
  thickness 2
  '
  color 1,1,0,1
  pushstate
  move xa-.5,ya-1
  gprint "A"
  popstate
  pushstate
  move xb+1,yb+1
  gprint "B"
  popstate
  pushstate
  move xc-1,yc+1
  gprint "C"
  popstate
  '
    color .8,.0,.8
  float zp=-1.001
  glBegin GL_TRIANGLES
  glVertex3f xa,ya,zp
  glVertex3f xb,yb,zp
  glVertex3f xc,yc,zp
  glEnd
  '
  color 0,.9,.9
  glBegin GL_LINES
  glVertex2f xa,ya
  glVertex2f xb,yb
  glVertex2f xb,yb
  glVertex2f xc,yc
  glVertex2f xc,yc
  glVertex2f xa,ya
  glEnd


  move 5

  'if not pick then
    if key[49] then picked=100 'keypress '1'
    if key[50] then picked=200 'keypress  '2'
    pushstate
    move -20,12
    static sys tally
    timemark t2
    scale 1.0
    '
    int dp=3
    '
    macro pr1(a) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      printl ""
    end macro
    '
    macro pr2(a,b) 'PRINTING LIST
    -----------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      printl ""
    end macro
    '
    macro pr3(a,b,c) 'PRINTING LIST
    ------------------------------
      pushstate : color .5,1,1 : print a : popstate
      pushstate : color 1,1,.5 : move 4 : print str(b,dp) : popstate
      pushstate : color 1,1,.5 : move 8 : print str(c,dp) : popstate
      printl ""
    end macro
    '
    '
    'DISPLAY INFO
    -------------
    picklabel 0

    pushstate
    scale 2
    color 1,1,1
    print "Triangle Data"
    popstate
    pr1 ""
    pr1 ""
   'pr2 "Action Code:   ", act
   'pr2 "indexbase      ", indexbase
   'pr2 "Keyboard Code: ", keyd
    pr2 "Picked ID:     ", picked
    '
    pr3 "Point A: ", str(xa,3), ya
    pr3 "Point B: ", str(xb,3), yb
    pr3 "Point C: ", str(xc,3), yc
    '
    float ab,ac,bc,ar,ht,hb
    '
    ab=hypot(xa-xb, ya-yb)
    ac=hypot(xa-xc, ya-yc)
    bc=hypot(xb-xc, yb-yc)
    '
    hb=0.5* ( ab*ab - ac*ac + bc*bc ) / bc
    ht=sqr(ab*ab-hb*hb)
    ar=0.5*bc*ht

    'ANGLES
    float na,nb,nc
    nb=deg(asin(ht/ab))
    nc=deg(asin(ht/ac))
    na=180-nb-nc

    pr1 ""
    pr2 "Angle A:",na
    pr2 "Angle B:",nb
    pr2 "Angle C:",nc
   
    pr1 ""
    pr2 "Line AB:",ab
    pr2 "Line AC:",ac
    pr2 "Line BC:",bc
    pr2 "Left base:",hb
    pr2 "Height:",ht
    pr2 "Area:", ar
    pr1 ""
    '
    picklabel 0
    popstate
  'end if
  '-------------------- //
  'end procedure 'main
  '-------------------- //
  static single ra,ri,angi1=.5
  static sys    initscene
 
  '---------- //
  'DozyFrame 'causes overlapped sliders
  '---------- //
  glscalef 18,18,18
  '------------------------------
 'glClearColor 0.5, 0.5, 0.7, 0
  glClearColor 0.1, 0.2, 0.1, 0
  BeginPick
  '
  glColor4f .99,.99,.99,.99
  'glEnable GL_TEXTURE_2D
  '
  'RENDERED LOWEST FIRST (FOR TRANSPARENCY BLENDING)
  '
  %                    ordn=3
  static ControlPanelA cb[ordn]
  static int           ord[16]
  static int           idb[16]
  '
  if closing
    int i
    for i=1 to 3
      cb[i].destructor
    next
    exit sub
  endif
 
  '
  'INITIAL PLACEMENT ETC
  '
  if initscene=0
    ord={1,2,3}
    idb={0,100,200}
    cb[1].x=.0 : cb[1].y=.0
    cb[2].x=.1 : cb[2].y=.05
    cb[3].x=.2 : cb[3].y=.10
    int i
    'set scale
    for i=1 to ordn : cb[i].sc=2.5 : next
    initscene=1
  end if
  '
  'ORDER OF BUILD (SUPPORTING TRANSPARENCY)
  '
  if picked and bleft
    int a=1+trunc(picked/100)
    PlaceTop(a,ord,ordn)
  end if
  '
  'BUILD
  '
  glpushmatrix
  static float layr=.001
  static float f = -1 - layr*ordn
  gltranslatef .0, .0, f
  int i,j
  for i=1 to ordn
    j=ord[i]
    cb[j].act idb[j]
    gltranslatef .0, .0, layr 'next micro-layer in front
  next
  glpopmatrix
  '
  '
  EndPick
  '
 
'  ang1+=angi1
'  if ang1>=360 then ang1-=360
 
  end procedure 'main
  EndScript

The sliders touch zone is it bit low, so I will need to adjust it in controls.inc
#6
Unleash the power of AI with the Smart Package Robot! 🤖✨ Attach the capabilities of top AI systems to any program or browser with ease. 🌐🔗 In this demo, I'm empowering Twitter with the Smart Package Robot's AI magic. 🐦💫 Speak your tweets instead of typing! 🗣�✍️

Plus, get instant rewrites, translations, Emojis and Hashtags and even rhymes on demand. 🔄🌍🎶

Want stunning images? The Smart Package Robot has you covered there too! 🖼�🎨
And that all is in the Code below.✍️
🎨🎶

The code snippet demonstrates the utilization of the new autoincrement variable feature 🔄, which is a variable that automatically increases its value with each use. It's initialized with the 'RIV.' command. 🚀

#Coding #AutoIncrement #ProgrammingTips #CodeSnippet #DeveloperTools #TechTalk 🧑�💻👩�💻💻⌨️🖱�🔢🆙


#SmartPackageRobot #AIRevolution #TechInnovation #TwitterAI #VoiceToText #LanguageTranslation #CreativeRhymes #DigitalArt #TechMagic #ArtificialIntelligence 🤖🌟🐦🌐🔗🗣�✍️🔄🌍🎶🖼�🎨

(Translated)
Entfessele der KI ihre Macht, mit des Smarten Paketboten Pracht! 🤖 Verknüpfe Top-KI's Fähigkeiten, mit Programmen, ohne Mühen, sogleich. 🌐 In dieser Demo, sieh, wie ich Twitter belebe, mit des Boten KI-Zauber, so erhebe. ✨ Sprich deine Tweets, statt zu tippen, lass die Worte einfach fließen! 🎙� Erhalte Neuschreibungen, Übersetzungen, gar Reime auf Abruf, ohne Mühen. 🔄🌍📝 Begehrst du atemberaubende Bilder? Der Smarte Paketbote hält sie bereit, immer milder. 🎨🖌�

#SmartPackageRobot #AIRevolution #TechInnovation #TwitterAI #VoiceToText #LanguageTranslation #CreativeRhymes #DigitalArt #TechMagic #ArtificialIntelligence 🤖🌐✨🎙�🔄🌍📝🎨🖌�

TwitterBar_02.png
TwitterBar_01.png
AI_Rewzept.png
'
'SPR Script-file: Twitterbar
'Purpose:
'Creation date: 11-11-2023 at 20:18:48
'===========================================================
'#EXE:?path\
'#SPI:ForceWrite
'#ICS:20
'
' COMMANDS:
' RUN FIREFOX and open Site www.fa2.de
' P1 - Site that should be opened
' %Firefox www.fa2.de
'
' Open a new TAB-Page
' P1 - Site to be opened
' P2 - optional - Number of site if multiple with same Text
' %New_TAB
'
' Locate the Firefox Mainwindow
' %Locate_TW
'
' Trage Link in Firefox ein
' P1 - Link to open
' %Firefox_Set_Site $$LNK
'
' Close Firefox
' %Firefox_Close

AIC.Set Key|file
SDO.Set Key|file
DLT.Set Key|File

'GTO.Start
'===========================================================
' Main Script
'===========================================================
' This is the site we are going to open
VAR.$$LNK=https://twitter.com/TheoGottwald/following
VAR.$$PAR=-new-window
VAR.$$TAB=People followed

' This will locate FF and run it
' If the window is too large (1840,1644) change size in Library
VAR.$$PAX="$$LNK" $$PAR
%Firefox $$PAX
WII.10
:Start
' Sample Click
%Locate_TW

' Start the Button-Bar
PIL.$$REA|01

' Make the PlugIn visible
PIS.$$REA|hide

' Set Distance between buttons (vertical in Points)
PIS.$$REA|sbvd|4

' Set Distance vertical in Points, not needed here
PIS.$$REA|sbvd|4

' Plugin is horizontal
PIS.$$REA|sv

' Make the PlugIn visible
PIS.$$REA|show

' attach the Plugin to the window
PIS.$$REA|attach|$$HWN|2|X
PIS.$$REA|SetButtonsHSize|80
' Set text on Button 1 to 13
RIV.1
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Dictate
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Dict.Rh.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Rework
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. P. Comm.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. N. Comm.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Fun.Comm.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. To Rhyme
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. To Eng.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. To Ger.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. To Spa.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Undo Txt.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Pic S/R
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Pic S/R
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. What is Pic.
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Command
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Dump ASC
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Test
$$NUM=#aiv#
PIS.$$REA|sBt|$$NUM|$$NUM. Ende

' Will set the number of visible Buttons to 18
PIS.$$REA|SetButtonNumber|$$NUM
DBP.$$NUM Buttons created

DOL.1
  PIW.$$REA|$$MES
  STR.Split String|$$MES|!|$$BNU|$$BME
  JIV.$$BME=normal!|endloop
  VBT.$$BME
  SCS.$$BME
  CAS.P!
    GTO.weiter
  CAS.R!
    GTO.weiter
  CAE.
    GTO.endloop
  ESL.

  JIZ.$$JMP|endloop
  :weiter 
  ' Button-Number
  VBT.$$BNU
  VBT.$$BME 
 
  RIV.1
  SCN.$$BNU
  CAN.#aiv#
    GSB.DoDictate
  CAN.#aiv#
    GSB.DoDictRh
  CAN.#aiv#
    GSB.DoRework
  CAN.#aiv#
    GSB.DoPosCom
  CAN.#aiv#
    GSB.DoNegCom
  CAN.#aiv#
    GSB.DoFunny
  CAN.#aiv#
    GSB.DoRhyme
  CAN.#aiv#
    GSB.ToEng
  CAN.#aiv#
    GSB.ToGer
  CAN.#aiv#
    GSB.ToSpan
  CAN.#aiv#
    GSB.Undo
  CAN.#aiv#
    GSB.DoPIA
  CAN.#aiv#
    GSB.DoPIB
  CAN.#aiv#
    GSB.WhatIs
  CAN.#aiv#
    GSB.DoCommand
  CAN.#aiv#
    GSB.DumpASC
  CAN.#aiv#
    GSB.Test 
  CAE.
    GTO.enz
  ESL.
 
  :endloop
  NEW.t
    BRK.
  EIF.
OOP.
:enz
END.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:Completion_Unicode
AIC.Set Model Completion|1
AIC.Ask Comp Unicode|$$PRO|$$RES
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:Completion
AIC.Set Model Completion|1
AIC.Ask Completion|$$PRO|$$RES
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:Chat
AIC.SetModel Chat|1
AIC.Ask Chat|$$PRO|$$RES
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:Chat_Unicode
AIC.SetModel Chat|5
AIC.Ask Chat Unicode|$$PRO|$$RES
RET.
'-----------------------------------------------------------
' Buttons
'-----------------------------------------------------------
:DoDictate
AIC.Dictate Letter|$$MYT
DBP.$$MYT
CLP.t|$$MYT|1
MSB.550|2
:overB1
RET.

:DoDictRh
GSB.DoDictate
GSB.DoRhyme
GTO.Beep
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoRework
CLP.r|$$MYT|1
$$KEP=$$MYT
GSB.Pro_02
$$PRO+ Text: $$MYT
GSB.Chat_Unicode
DBP.$$RES
'CLP.t|$$RES|1
MSB.660|2
MSB.660|2
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoPosCom
CLP.r|$$MYT
$$KEP=$$MYT
GSB.Pro_01|positive Comment
$$PRO+ Text: $$MYT
AIC.Set Model Completion|1
AIC.Ask Completion|$$PRO|$$RES
GTO.ClipBeep
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoNegCom
CLP.r|$$MYT
$$KEP=$$MYT
GSB.Pro_01|negative Comment
$$PRO+ Text: $$MYT
AIC.Set Model Completion|0
AIC.Ask Completion|$$PRO|$$RES
GTO.ClipBeep
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoFunny
CLP.r|$$MYT
$$KEP=$$MYT
GSB.Pro_03|very funny Comment
$$PRO+ Text: $$MYT
GSB.Chat_Unicode
UTA.$$RES
DBP.$$RES
'GTO.ClipBeep
MSB.660|2
MSB.860|1
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoRhyme
CLP.r|$$MYT
$$KEP=$$MYT
GSB.Pro_04
$$PRO+ Text: $$MYT
GSB.Chat_Unicode
UTA.$$RES
DBP.$$RES
MSB.660|2
MSB.860|1
RET.
'-----------------------------------------------------------
' To Eng.
'-----------------------------------------------------------
:ToEng
CLP.r|$$MYT
$$INS=EN
DLT.Translate Text Unicode|$$MYT|$$RES||$$INS
DBP.$$RES
GTO.Beep
'-----------------------------------------------------------
' To Germ.
'-----------------------------------------------------------
:ToGer
CLP.r|$$MYT
$$INS=DE
DLT.Translate Text Unicode|$$MYT|$$RES||$$INS
DBP.$$RES
GTO.Beep
'-----------------------------------------------------------
' To Span.
'-----------------------------------------------------------
:ToSpan
CLP.r|$$MYT
$$INS=SP
DLT.Translate Text Unicode|$$MYT|$$RES||$$INS
DBP.$$RES
GTO.Beep
'-----------------------------------------------------------
:ClipBeep
CLP.t|$$RES
:Beep
$$KEP=$$MYT
MSB.660|2
MSB.660|2
MSB.860|1
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' Undo
'-----------------------------------------------------------
:Undo
'PRT. Was here with: $$BME
CLP.r|$$MYT
DBP.$$KEP
CLP.t|$$KEP
$$KEP=$$MYT
MSB.660|2
MSB.660|2
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoPIA
IVS.$$BME=P!
  ANA.From Clipboard|$$KEA 
  SBT.Saved to A
  PIS.$$REA|sBt|11|A OK! 
ELS.
  ANA.To Clipboard|$$KEA
  SBT.Restored from A
EIF.
MSB.560|2
MSB.860|2

RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoPIB
IVS.$$BME=P!
  SBT.Saved to B
  ANA.From Clipboard|$$KEB 
  PIS.$$REA|sBt|11|B OK!
ELS.
  ANA.To Clipboard|$$KEB 
  SBT.Restored from B
EIF.
MSB.560|2
MSB.860|2
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:WhatIs
$$KEC=3
$$FIL=?path\Temp.jpg
ANA.From Clipboard|$$KEC
ANA.Save|$$KEC|$$FIL
$$PRO=What is this picture? Please tell me as the german poet Schiller and Hashtags to the result.
AIC.Ask Vision|$$FIL|$$PRO|$$RES
GSB.ToClip
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DoCommand
CLP.r|$$MYT
$$KEP=$$MYT
GSB.Pro_05|$$MYT
MBX.$$PRO
AIC.Set Model Chat|1
AIC.Ask Chat|$$PRO|$$RES
DBP.$$RES
GTO.ToClip
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:DumpASC
CLP.r|$$MYT|1
PRT.$$MYT|h
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:Test
CLP.r|$$MYT|1
VAR.$$RES=$$MYT
CLP.t|$$RES|1
MSB.660|2
MSB.660|2
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
:ToClip
CLP.t|$$KEP
CLP.$$RES
MSB.660|2
MSB.660|2
DBP.$$RES
RET.

'-----------------------------------------------------------
:Pro_01
$$INS=§§_01
$$PRO=Act as a Twitter-Influencer.
$$PRO+ Make a $$INS comment from the text below.
$$PRO+ Add surprising Arguments to proof our standpoint.
$$PRO+ Make the result funny and highly intelligent.
$$PRO+ Then add  Linefeed and then
$$PRO+ Add space-sparated Hashtags to the end of the text.
$$PRO+ Return only the refined Twitter-Text in the same language as the Text below is.
RET.
'-----------------------------------------------------------
:Pro_02
$$PRO=Correct and refine the text below and add emojis for Twitter.
$$PRO+ then add double Linefeeds for best readability.
$$PRO+ Finally add a Linefeed and then Add Hashtags and lots of Emojis for Twitter to the end of the text.
$$PRO+ Return only the refined Twitter-Post.
'$$PRO+ followed by a Linefeed and then the Space-Separted Hashtags $crlf$
RET.
'-----------------------------------------------------------
:Pro_03
$$INS=§§_01
$$PRO=Act as a Twitter-Influencer. Read the text below and then
$$PRO+ Make a $$INS comment about the text keeping the original language.
$$PRO+ Add to every Line Emojis that fit well.
$$PRO+ Analyze the Text then created a funny Joke or comment on that topic.
$$PRO+ Let it be a Joke or something suprising funny and highly intelligent.
$$PRO+ Then add  Linefeed and then
$$PRO+ Add space-sparated Hashtags to the end of the text.
'$$PRO+ Return only the refined Twitter-Text in the same language as the Text below is.
RET.
'-----------------------------------------------------------
:Pro_04
$$POE=Goethe
$$PRO=Act as the Poet $$POE, yet keep the language original as it was.
$$PRO+ Refine the following Text as $$POE, keeping the sense and original language.
$$PRO+ Add to every Line Emojis that fit well.
$$PRO+ Return only the refined Twitter-Text with Emojis.
$$PRO+ Add at the end a Linefeed and then Space-Separted Hashtags $crlf$
RET.
'-----------------------------------------------------------
:Pro_05
$$PRO=§§_01
$$PRO+ Return only the refined Twitter-Text in German plus.
$$PRO+ Add at the end  Linefeed aand then Space-Separted Hashtags $crlf$
RET.
'-----------------------------------------------------------
:Pro_06
$$PRO=Mach mir ein Rezept mit edlem Gemüse, Pfeffer, etwas Käse, Butter. Achte auf Gesundheit und Nährstoffe.
$$PRO+ Dann agiere wie zwei Experten. Experte A ist Goethe, der dieses Rezept in einen Goethe-mäßigen Reim umwandelt. Experte B ist ein Deutschexperte, der diesen Goethe-Reim nochmal von den Wörtern her so korrigiert, dass es sich perfekt reimt. Den Reim, der dann herauskommt, gibt nochmal Goethe zur Korrektur und macht etliche Emojis rein und formatiere es schön mit Zeilenumbrüchen für Twitter.
RET.

'===========================================================
' Twitter specific-Sub-Programmes
'===========================================================

'-----------------------------------------------------------
:NotAus
' Not AUS
IEK.LSHIFT
  MBX.Ending
  END.
EIF.
RET.
'-----------------------------------------------------------
:NextPage
%Locate_TW
MLI.t|100,1000
SDA.{PGDN}
PAU.1
RET.

'-----------------------------------------------------------
'
'-----------------------------------------------------------



'===========================================================
' Sub-Programmes
'===========================================================
'
: %Locate_TW 0
GSB.Loc_TW
END%

:Loc_TW
NEW.$$HWN
  STW.ct|MozillaWindowClass|Mozilla Firefox
  GSB.Resize_FF
  HTV.$$HWN 
ELS.
  STW.h|$$HWN
  GSB.Resize_FF
EIF.
RET.
'-----------------------------------------------------------
:Resize_FF
'SWP.0,0|1840,1944|T
SWP.0,0|1368,1829|T
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
' Kann ohne Parameter aufgerufen werden,
' oder mit einem Parameter mit dem Link für die neue Site
'
: %New_TAB 0
#IF PARAMS=1
SAV.Save|$$LNA
VAR.$$LNA=§§§01
GSB.New_TAB
PAU.1
%Firefox_Set_Site $$LNA
SAV.Restore
#EIF
#IF PARAMS=0
GSB.New_TAB
#EIF
END%
'-----------------------------------------------------------
:New_TAB
GSB.Loc_TW
AGR.43!WII.MLI.|Einen neuen Tab öffnen (Strg+T)||1|3|60
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
'
: %Firefox_Set_Site 1
SAV.Save|$$TXT
GSB.Set_Site|§§§01
SAV.Restore
END%
:Set_Site
VAR.$$TXT=§§_01
GSB.Loc_TW
AGR.43!WII.MLI.|Startseite||1|3|60
NAV.Rr|R|42
MLI.
KBC.Paste Over|$$TXT
SKP.{Enter}
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
'
' P1 - Text that is on the TAB we want
' P2 - optional the number of the TAB if it has the same Text like on other TABs
'  normally Nr. is 1
' The minimum Number of Parameters is 1 thats why we have a "1" here after The Macroname
'
: %Locate_TAB 1
SAV.Save|$$NUM|$$TXT
VAR.$$TXT=§§§01
#IF PARAMS=1
VAR.$$NUM=1
GSB.Loc_TAB
#EIF
#IF PARAMS=2
VAR.$$NUM=§§§02
GSB.Loc_TAB|§§§01
#EIF
SAV.Restore
END%
'-----------------------------------------------------------
:Loc_TAB
GSB.Loc_TW
AGR.42!WII.MOS.|$$TXT||$$NUM|3|60
GSB.Loc_TW
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
'
: %Firefox 1
GSB.Lab_Run_Firefox|§§§01
END%
'-----------------------------------------------------------
:Lab_Run_Firefox
SAV.Save|$$PAT|$$NAM|$$RES|$$EXE|$$LNK
'-----------------------------------------------------------
IAI.Mozilla Firefox
  VAR.$$LNK=§§_01
  GSB.Lab_FF_starten
ELS.
  MBX.Firefox ist nicht installiert.
  END.
EIF.
RET.

:Lab_FF_starten
STW.ctwXo|MozillaWindowClass|Mozilla Firefox|1|Run_it

RET.
'-----------------------------------------------------------
:Run_it
VAR.$$NAM=$tos$
GII.$$NAM|$$RES|u
BLB.$$RES|$$RES
BLB.$$RES|$$RES
  ' $$PAT enthält Programmpfad ohne "\"
VAR.$$PAT=$$RES
VBT.$$PAT|"
VAR.$$EXE=$$PAT\Firefox.exe
IEF.$$EXE
  EXE.$$EXE|$$LNK
ELS.
  MBX.Kann FF nicht starten.
  END.   
EIF.
SAV.Restore
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------
: %Firefox_Close 0
GSB.Lab_Close_FF
END%

:Lab_Close_FF
GSB.Loc_TW
CLW.$$HWN
STW.ct|MozillaDialogClass|schließen?&OR:close
' AGR. uses a waiting time of 60 seconds, you can change it below.
AGR.43!WII.MOS.|Tabs schließen&OR:close||1|3|60
MLI.
RET.
'-----------------------------------------------------------
'
'-----------------------------------------------------------



#7
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Theo Gottwald - Yesterday at 01:14:38 PM
QuoteHere's the complete string library for OxygenBasic, including all the previously discussed functions. This library covers basic string operations, handling comma-separated values, and a simple pattern matching function.
```basic
' Complete String Library for OxygenBasic

' Concatenates two strings
Function strConcat(str1 as string, str2 as string) as string
    return str1 & str2
End Function

' Returns the length of a string
Function strLength(str as string) as int
    return len(str)
End Function

' Converts a string to uppercase
Function strToUpper(str as string) as string
    return ucase(str)
End Function

' Converts a string to lowercase
Function strToLower(str as string) as string
    return lcase(str)
End Function

' Reverses a string
Function strReverse(str as string) as string
    Local reversed as string
    For i as int = len(str) to 1 step -1
        reversed &= mid(str, i, 1)
    Next
    return reversed
End Function

' Checks if a string contains another string
Function strContains(mainStr as string, subStr as string) as bool
    return instr(mainStr, subStr) > 0
End Function

' Replaces a substring within a string
Function strReplace(original as string, findStr as string, replaceStr as string) as string
    Local result as string
    Local startPos as int = 1
    Local pos as int

    While true
        pos = instr(startPos, original, findStr)
        if pos = 0 then
            result &= mid(original, startPos)
            exit while
        end if
        result &= mid(original, startPos, pos - startPos) & replaceStr
        startPos = pos + len(findStr)
    Wend

    return result
End Function

' Splits a string into an array based on a delimiter
Function strSplit(str as string, delimiter as string) as string[]
    Local parts() as string
    Local startPos as int = 1
    Local pos as int
    Local index as int = 0

    While true
        pos = instr(startPos, str, delimiter)
        if pos = 0 then
            redim preserve parts(index)
            parts(index) = mid(str, startPos)
            exit while
        end if
        redim preserve parts(index)
        parts(index) = mid(str, startPos, pos - startPos)
        startPos = pos + len(delimiter)
        index += 1
    Wend

    return parts
End Function

' Splits a comma-separated string into an array
Function strSplitCSV(str as string) as string[]
    return strSplit(str, ",")
End Function

' Joins an array of strings into a comma-separated string
Function strJoinCSV(strings() as string) as string
    Local result as string
    For i as int = 0 to ubound(strings)
        result &= strings(i)
        if i < ubound(strings) then
            result &= ","
        end if
    Next
    return result
End Function

' Simple pattern matching function
Function strMatchPattern(str as string, pattern as string) as bool
    Local sPos as int = 1
    Local pPos as int = 1
    Local sLen as int = len(str)
    Local pLen as int = len(pattern)
    Local match as int = 0
    Local star as int = 0

    While sPos <= sLen
        if pPos <= pLen and (pattern[pPos] = str[sPos] or pattern[pPos] = '?') then
            pPos += 1
            sPos += 1
            continue
        end if

        if pPos <= pLen and pattern[pPos] = '*' then
            star = pPos
            match = sPos
            pPos += 1
            continue
        end if

        if star <> 0 then
            pPos = star + 1
            match += 1
            sPos = match
            continue
        end if

        return false
    Wend

    While pPos <= pLen and pattern[pPos] = '*'
        pPos += 1
    Wend

    return pPos > pLen
End Function

' Example usage of the string library
Function Main() as int
    Local myStr as string = "Hello, World!"
    print "Original: " & myStr
    print "Uppercase: " & strToUpper(myStr)
    print "Lowercase: " & strToLower(myStr)
    print "Reversed: " & strReverse(myStr)
    print "Contains 'World': " & strContains(myStr, "World")
    print "Replace 'World' with 'OxygenBasic': " & strReplace(myStr, "World

", "OxygenBasic")

    Local csvStr as string = "apple,banana,orange"
    Local fruits() as string = strSplitCSV(csvStr)
    print "Fruits from CSV: "
    For i as int = 0 to ubound(fruits)
        print fruits(i)
    Next

    Local joinedCSV as string = strJoinCSV(fruits)
    print "Joined CSV: " & joinedCSV

    If strMatchPattern("Hello, World!", "H*o, W*d!") then
        print "Pattern matches!"
    Else
        print "Pattern does not match."
    End If

    return 0
End Function

Main()
```

### Features of the String Library:
- Basic string operations like concatenati
Quoteon, length, uppercase, lowercase, and reversal.
- Functions to check if a string contains another string, replace substrings, and split strings based on delimiters.
- Additional functions to handle CSV data.
- A simple pattern matching function to match strings against patterns with `*` and `?` wildcards.

### Usage:
- The `Main` function at the end demonstrates how to use the various functions in the library.
- This library is a starting point and can be further expanded or optimized based on your specific requirements and use cases.

### Testing and Integration:
- Thoroughly test each function, especially the pattern matching one, as it's a simplified implementation.
- Integrate this library into your OxygenBasic projects as needed. You may also consider adding error handling or optimizations for better performance.

Now some ASM ...

QuoteReplacing a function like `strReverse` (reversing a string) with x86 assembly code in OxygenBasic is a bit more complex, as it involves low-level string manipulation. However, it's an interesting exercise in blending high-level programming with assembly for performance-critical tasks.

Below, I'll show you how to rewrite the `strReverse` function using inline x86 assembly within OxygenBasic. Keep in mind that working with assembly requires a good understanding of the CPU's architecture and the calling conventions of your environment.
```basic

' Reverses a string using x86 assembly
Function strReverseASM(str as string) as string
    Local length as int = len(str)
    if length = 0 then return ""

    Local reversed as string
    space(reversed, length)

    asm
        mov esi, str            ; Source string pointer
        mov edi, reversed       ; Destination string pointer
        add esi, length         ; Move to the end of the source string
        dec esi                 ; Adjust for 0-based index
        mov ecx, length         ; Counter for the length of the string

    reverse_loop:
        mov al, [esi]           ; Load the current character from source
        mov [edi], al           ; Store it in the destination
        dec esi                 ; Move to the previous character in source
        inc edi                 ; Move to the next character in destination
        loop reverse_loop       ; Continue for the length of the string
    end asm

    return reversed
End Function

Quote### Explanation:
- The `strReverseASM` function uses inline assembly to reverse the string.
- It first calculates the length of the string and prepares a destination string of the same length.
- The assembly code then iterates over the string from the end to the beginning, copying each character to the destination string.

### Important Notes:
- This assembly code is written for x86 architecture and assumes a specific calling convention that matches OxygenBasic's environment.
- Inline assembly in OxygenBasic is powerful but requires careful handling, especially with regards to pointer arithmetic and memory access.
- Testing is crucial to ensure that the function behaves correctly for all edge cases, such as empty strings or very long strings.

This function provides an example of how you can integrate assembly code into your OxygenBasic programs for specific tasks where low-level control and optimization are necessary.
#8
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Theo Gottwald - Yesterday at 01:05:09 PM
QuoteCreating a complete and ready-to-compile 3D interactive OpenGL application in OxygenBasic involves setting up a window, initializing an OpenGL context, handling user input, and performing 3D rendering. Below is an example script that demonstrates a rotating 3D cube, which the user can control using the arrow keys.

This script should compile and run in an OxygenBasic environment with OpenGL support. However, remember that OpenGL setup can vary based on system configurations and drivers.
```basic
' 3D Interactive Cube in OxygenBasic using OpenGL
uses rtl32
uses console
uses ogl ' Include the OpenGL library

' Global variables for rotation
global xRotation as float = 0.0
global yRotation as float = 0.0
global zRotation as float = 0.0

' Function to draw a cube
Sub DrawCube()
    glBegin(GL_QUADS)
   
    ' Front face (in red)
    glColor3f(1.0, 0.0, 0.0)
    glVertex3f(-1.0, -1.0,  1.0)
    glVertex3f( 1.0, -1.0,  1.0)
    glVertex3f( 1.0,  1.0,  1.0)
    glVertex3f(-1.0,  1.0,  1.0)
   
    ' Other faces (in different colors)
    ' Define the vertices for the other faces with different colors

    glEnd()
End Sub

' Window callback function
Function WndProc(hWnd as sys, uMsg as uint, wParam as sys, lParam as sys) as sys callback
    Select Case uMsg
        Case WM_KEYDOWN
            Select Case wParam
                Case VK_LEFT
                    yRotation -= 5.0
                Case VK_RIGHT
                    yRotation += 5.0
                Case VK_UP
                    xRotation -= 5.0
                Case VK_DOWN
                    xRotation += 5.0
            End Select
            return 0
        Case WM_CLOSE
            PostQuitMessage(0)
            return 0
        Case WM_DESTROY
            return 0
        Case Else
            return DefWindowProc(hWnd, uMsg, wParam, lParam)
    End Select
End Function

' Main program
Function WinMain(hInstance as sys, hPrevInstance as sys, lpCmdLine as sys, nCmdShow as int) as int
    ' Register the window class
    Local wc as WNDCLASSEX
    wc.cbSize = SizeOf(WNDCLASSEX)
    wc.style = CS_HREDRAW or CS_VREDRAW
    wc.lpfnWndProc = @WndProc
    wc.cbClsExtra = 0
    wc.cbWndExtra = 0
    wc.hInstance = hInstance
    wc.hbrBackground = COLOR_WINDOW + 1
    wc.lpszMenuName = NULL
    wc.lpszClassName = "OGLWindow"
    RegisterClassEx(@wc)

    ' Create the window
    Local hWnd as sys
    hWnd = CreateWindowEx(0, "OGLWindow", "3D Cube Demo with OxygenBasic", WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL)
    ShowWindow(hWnd, nCmdShow)
    UpdateWindow(hWnd)

    ' Initialize OpenGL
    Local hDC as sys, hRC as sys
    hDC = GetDC(hWnd)
    SetPixelFormat(hDC, ChoosePixelFormat(hDC, @pfd), @pfd)
    hRC = wglCreateContext(hDC)
    wglMakeCurrent(hDC, hRC)

    ' Set up a 3D perspective
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluPerspective(45.0, 640.0/480.0, 1.0, 100.0)
    glMatrixMode(GL_MODELVIEW)

    ' Enable depth testing for 3D rendering
    glEnable(GL_DEPTH_TEST)

    ' Main message loop
    Local msg as MSG
    While GetMessage(@msg, NULL, 0, 0)
        TranslateMessage(@msg)
        DispatchMessage(@msg)

        ' Clear the screen and depth buffer
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        ' Transformations for rotating the cube
        glTranslatef(0.0, 0.0, -5.0)
        glRotatef(xRotation, 1.0, 0.0, 0.0)
        glRotatef(yRotation, 0.0, 1.0, 0.0)
        glRotatef(zRotation, 0.0, 0.0, 1.0)

        ' Draw the cube
        DrawCube()

       

 ' Swap buffers
        SwapBuffers(hDC)
    End While

    ' Cleanup
    wglMakeCurrent(NULL, NULL)
    wglDeleteContext(hRC)
    ReleaseDC(hWnd, hDC)

    return msg.wParam
End Function

' Start the program
WinMain(GetModuleHandle(NULL), NULL, Command(), SW_SHOWDEFAULT)
```

Quote### Key Features of the Code:
- **3D Cube Rendering**: The `DrawCube` subroutine renders a cube using OpenGL.
- **Keyboard Interaction**: The `WndProc` function handles keyboard input to control the cube's rotation.
- **3D Transformations**: The main loop includes translation and rotation transformations to position and rotate the cube in 3D space.
- **Depth Testing**: Enabled for proper 3D rendering.
- **Perspective Setup**: A 3D perspective is set up for rendering the cube.

### Considerations:
- **Cube Faces**: The example includes only the front face of the cube. You'll need to define the vertices for the other faces.
- **Testing and Environment**: Make sure to test this script in your specific development environment. Adjustments may be needed based on your OpenGL version and setup.

This script provides a basic structure for a 3D interactive application using OpenGL in OxygenBasic. It's a starting point for more complex 3D projects.
#9
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Theo Gottwald - Yesterday at 12:59:26 PM
QuoteCertainly! Below is the complete code for a simple interactive OpenGL slider in OxygenBasic. This script includes the entire structure, from window creation to the main loop and cleanup. It's ready to compile and run, given you have the necessary OpenGL and OxygenBasic setup on your system.
```basic
' Simple Interactive OpenGL Slider Demo in OxygenBasic
uses rtl32
uses console
uses ogl ' Include the OpenGL library

' Slider Properties
type Slider
    x as float
    y as float
    width as float
    height as float
    value as float
end type

' Global variables
global mySlider as Slider
global dragging as bool
global dragOffsetX as float

' Function to check if a point is inside a rectangle
function PointInRect(px as float, py as float, rx as float, ry as float, rw as float, rh as float) as bool
    return px >= rx and px <= rx + rw and py >= ry and py <= ry + rh
end function

' Function to handle mouse events
function HandleMouseEvent(x as int, y as int, buttonDown as bool)
    ' Convert mouse coordinates to OpenGL coordinates
    y = 480 - y ' Invert the y-coordinate

    ' Check if the mouse is over the slider handle
    local handleX as float = mySlider.x + mySlider.value * mySlider.width
    if PointInRect(x, y, handleX - 5, mySlider.y - 5, 10, mySlider.height + 10) then
        if buttonDown then
            dragging = true
            dragOffsetX = handleX - x
        else
            dragging = false
        end if
    end if

    ' Update the slider value if dragging
    if dragging then
        mySlider.value = (x + dragOffsetX - mySlider.x) / mySlider.width
        mySlider.value = max(0, min(mySlider.value, 1)) ' Clamp the value between 0 and 1
    end if
end function

' Function to draw the slider
Sub DrawSlider(s as Slider)
    ' Draw the slider track
    glColor3f(0.5, 0.5, 0.5) ' Gray color
    glBegin(GL_QUADS)
        glVertex2f(s.x, s.y)
        glVertex2f(s.x + s.width, s.y)
        glVertex2f(s.x + s.width, s.y + s.height)
        glVertex2f(s.x, s.y + s.height)
    glEnd()

    ' Draw the slider handle
    local handleX as float = s.x + s.value * s.width
    glColor3f(0, 0, 1) ' Blue color
    glBegin(GL_QUADS)
        glVertex2f(handleX - 5, s.y - 5)
        glVertex2f(handleX + 5, s.y - 5)
        glVertex2f(handleX + 5, s.y + s.height + 5)
        glVertex2f(handleX - 5, s.y + s.height + 5)
    glEnd()
End Sub

' Declare the callback function for the window
Function WndProc(hWnd as sys, uMsg as uint, wParam as sys, lParam as sys) as sys callback
    Select Case uMsg
        Case WM_LBUTTONDOWN, WM_LBUTTONUP
            local mouseX as int = LOWORD(lParam)
            local mouseY as int = HIWORD(lParam)
            local buttonDown as bool = (uMsg = WM_LBUTTONDOWN)
            HandleMouseEvent(mouseX, mouseY, buttonDown)
            return 0
        Case WM_MOUSEMOVE
            if dragging then
                local mouseX as int = LOWORD(lParam)
                local mouseY as int = HIWORD(lParam)
                HandleMouseEvent(mouseX, mouseY, true)
            end if
            return 0
        Case WM_CLOSE
            PostQuitMessage(0)
            return 0
        Case WM_DESTROY
            return 0
    End Select
    return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

' Main program
Function WinMain(hInstance as sys, hPrevInstance as sys, lpCmdLine as sys, nCmdShow as int) as int
    ' Register the window class
    Local wc as WNDCLASSEX
    wc.cbSize = SizeOf(WNDCLASSEX)
    wc.style = CS_HREDRAW or CS_VREDRAW
    wc.lpfnWndProc = @WndProc
    wc.cbClsExtra = 0
    wc.cbWndExtra = 0
    wc.hInstance = hInstance
    wc.hbrBackground = COLOR_WINDOW + 1
    wc.lpszMenuName = NULL
    wc.lpszClassName = "OGLWindow"
    RegisterClassEx(@wc)

    ' Create the window
    Local hWnd as sys


    hWnd = CreateWindowEx(0, "OGLWindow", "OpenGL Slider Demo with OxygenBasic", WS_OVERLAPPEDWINDOW,
                          CW_USEDEFAULT, CW_USEDEFAULT, 640, 480, NULL, NULL, hInstance, NULL)
    ShowWindow(hWnd, nCmdShow)
    UpdateWindow(hWnd)

    ' Initialize OpenGL
    Local hDC as sys, hRC as sys
    hDC = GetDC(hWnd)
    SetPixelFormat(hDC, ChoosePixelFormat(hDC, @pfd), @pfd)
    hRC = wglCreateContext(hDC)
    wglMakeCurrent(hDC, hRC)

    ' Set up a simple 2D projection
    glMatrixMode(GL_PROJECTION)
    glLoadIdentity()
    gluOrtho2D(0, 640, 480, 0)
    glMatrixMode(GL_MODELVIEW)

    ' Create and initialize the slider
    mySlider.x = 100
    mySlider.y = 200
    mySlider.width = 300
    mySlider.height = 20
    mySlider.value = 0.5 ' 50% position
    dragging = false

    ' Main message loop
    Local msg as MSG
    While GetMessage(@msg, NULL, 0, 0)
        TranslateMessage(@msg)
        DispatchMessage(@msg)

        ' Clear the screen
        glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)
        glLoadIdentity()

        ' Draw the slider
        DrawSlider(mySlider)

        ' Swap buffers
        SwapBuffers(hDC)
    End While

    ' Cleanup
    wglMakeCurrent(NULL, NULL)
    wglDeleteContext(hRC)
    ReleaseDC(hWnd, hDC)

    return msg.wParam
End Function

' Start the program
WinMain(GetModuleHandle(NULL), NULL, Command(), SW_SHOWDEFAULT)
```
Quote### Key Points:
- **Complete Code Structure**: This script includes everything from window creation, OpenGL initialization, event handling, to rendering and cleanup.
- **Basic Interactivity**: The slider can be clicked and dragged. This interaction is handled by mouse event functions.
- **2D Projection**: The script uses a simple 2D projection suitable for GUI elements like sliders.

### Before Running the Code:
- Ensure that your development environment is set up correctly with OxygenBasic and the necessary OpenGL libraries.
- If you encounter any issues or errors, they might be related to your specific system configuration or the version of OxygenBasic and OpenGL you are using.

This script should give you a functional starting point for a simple interactive OpenGL application in OxygenBasic.
#10
OxygenBasic Examples / Re: Tried GPT-4 with Oxygen Ba...
Last post by Theo Gottwald - Yesterday at 12:56:31 PM
QuoteAdding interactivity to the simple OpenGL slider in OxygenBasic requires handling mouse events to detect when the user clicks and drags the slider handle. Below is the modified version of the previous script with basic interactivity added.

This script will allow the user to click and drag the slider handle horizontally. Note that this is a basic implementation and may need further refinement for a full-featured application.

' Simple Interactive OpenGL Slider Demo in OxygenBasic
uses rtl32
uses console
uses ogl ' Include the OpenGL library

' Slider Properties
type Slider
    x as float
    y as float
    width as float
    height as float
    value as float
end type

' Global variables
global mySlider as Slider
global dragging as bool
global dragOffsetX as float

' Function to check if a point is inside a rectangle
function PointInRect(px as float, py as float, rx as float, ry as float, rw as float, rh as float) as bool
    return px >= rx and px <= rx + rw and py >= ry and py <= ry + rh
end function

' Function to handle mouse events
function HandleMouseEvent(x as int, y as int, buttonDown as bool)
    ' Convert mouse coordinates to OpenGL coordinates
    y = 480 - y ' Invert the y-coordinate

    ' Check if the mouse is over the slider handle
    local handleX as float = mySlider.x + mySlider.value * mySlider.width
    if PointInRect(x, y, handleX - 5, mySlider.y - 5, 10, mySlider.height + 10) then
        if buttonDown then
            dragging = true
            dragOffsetX = handleX - x
        else
            dragging = false
        end if
    end if

    ' Update the slider value if dragging
    if dragging then
        mySlider.value = (x + dragOffsetX - mySlider.x) / mySlider.width
        mySlider.value = max(0, min(mySlider.value, 1)) ' Clamp the value between 0 and 1
    end if
end function

' Declare the callback function for the window
Function WndProc(hWnd as sys, uMsg as uint, wParam as sys, lParam as sys) as sys callback
    Select Case uMsg
        Case WM_LBUTTONDOWN, WM_LBUTTONUP
            local mouseX as int = LOWORD(lParam)
            local mouseY as int = HIWORD(lParam)
            local buttonDown as bool = (uMsg = WM_LBUTTONDOWN)
            HandleMouseEvent(mouseX, mouseY, buttonDown)
            return 0
        Case WM_MOUSEMOVE
            if dragging then
                local mouseX as int = LOWORD(lParam)
                local mouseY as int = HIWORD(lParam)
                HandleMouseEvent(mouseX, mouseY, true)
            end if
            return 0
        Case WM_CLOSE
            PostQuitMessage(0)
            return 0
        Case WM_DESTROY
            return 0
    End Select
    return DefWindowProc(hWnd, uMsg, wParam, lParam)
End Function

' ... [Rest of the code remains the same] ...

' Main program
Function WinMain(hInstance as sys, hPrevInstance as sys, lpCmdLine as sys, nCmdShow as int) as int
    ' ... [Window creation and OpenGL initialization code] ...

    ' Create and initialize the slider
    mySlider.x = 100
    mySlider.y = 200
    mySlider.width = 300
    mySlider.height = 20
    mySlider.value = 0.5 ' 50% position
    dragging = false

    ' ... [Message loop and cleanup code] ...
End Function

' Start the program
WinMain(GetModuleHandle(NULL), NULL, Command(), SW_SHOWDEFAULT)
```
Quote### Key Changes for Interactivity:
1. **Global Variables**: Added global variables to keep track of the slider state and whether the user is dragging the handle.
2. **Mouse Event Handling**: Added `HandleMouseEvent` function to update the slider's value based on mouse movement.
3. **Window Procedure**: Modified `WndProc` to handle mouse button and mouse movement messages.
4. **Dragging Logic**: The script now updates the slider's position when the user clicks and drags the handle.

### Testing and Further Development:
- Ensure you test this script in your development environment as handling user input can be sensitive to specific system configurations.
- You might want to refine the dragging behavior or the visual representation of the slider for a smoother user experience.
- For a more complex application, consider enhancing the slider with more features like horizontal/vertical orientation, range sliders, etc.