Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Eduardo Jorge on September 03, 2022, 11:14:04 PM

Title: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 03, 2022, 11:14:04 PM
oxygen relies on macros to work with multidimensional arrays.
macro a(x,y) av(y*1024+x)
  dim int av[1024*1024]

  a(100,200)=42
  print a(100,200) ;42

for many this is difficult to deal with, and for projects with many arrays it is boring to create macros for each one, of course it is a tool that makes more complex things easier.
on ide they could combine to put them already distributed with oxygenbasic as easily as oxide to start.
oxygen is quite easy, so making these questions more accessible to those who are just curious but can't even make a little program work because to make the compilers work is another puzzle.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 04, 2022, 01:40:18 AM
Hi Eduardo,

You can also use a Type to define the second dimension for an array. It's an extra line of code, but no macros:


'array dims using udt
type yy int x[100]
yy y[1000]
int a
int i=10
int j=20
y[i].x[j]=123
a=y[i].x[j]
print a '123
print y[10].x[20] '123


You can also create arrays with mixed member types


'array dims using udt
'with mixed elements
type sy
  char c[16]
  int x[100]
end type
'
sy y[1000]
string t
int a
int i=10
int j=20
y[i].c="Hello"
y[i].x[j]=123
a=y[i].x[j]
'
'Hello  123
print y[i].c "  " y[i].x[j]
print y[10].c "  " y[10].x[20]

Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 04, 2022, 09:43:29 AM
well that is about arrays
and what a heck is so problematic to use single arrays or UDT members for
multi-dimensions ?

Charles

I really don't know why you still keeping old AsciEdit in Scintilla folder?

PLEASE feel free and add latest release of AurelEdit to this folder.
i compiled it with SC 040 and work well !

PS..If someone need it i can try build 64bit version?
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 04, 2022, 04:32:26 PM
Lol Charles, I think I'd rather stick with the macros.

Zlatko Vid, no problem using single arrays, not even with utd.
but when you think of tables, you think of a multidimensional array, and the standard usage you find is not that, mainly in Basic and in C, which are the bases of Oxygen.

the ease of executing a command line, creating a dll with oxygem can be a big draw for those who want simple things and are faced with the complications of making existing ide´s and compilers work.
if you attract the curious, you can attract people with more professional use and even people able to contribute.

there are several types of markets that, despite being small, if they have certain functions incorporated, could attract a lot of attention since in other platforms there are certain difficulties in implementing them.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 06, 2022, 05:15:58 PM
Eduardo

QuoteZlatko Vid, no problem using single arrays, not even with utd.
but when you think of tables, you think of a multidimensional array, and the standard usage you find is not that, mainly in Basic and in C, which are the bases of Oxygen.

the ease of executing a command line, creating a dll with oxygem can be a big draw for those who want simple things and are faced with the complications of making existing ide´s and compilers work.
if you attract the curious, you can attract people with more professional use and even people able to contribute.

there are several types of markets that, despite being small, if they have certain functions incorporated, could attract a lot of attention since in other platforms there are certain difficulties in implementing them.

how many BASIC users need or use tables or multi-dimensional arrays?
i all current activity around BASIC dialects ..there are just graphic progies and similar mumbo-jumbo

creating .dll with Oxygen basic cannot be simplier ..much simplier in many other compilers like FB or PB
another thing is ..if someone is soo lazy and can't write
$ filename "MyDLL.dll" ....i am asking you ..is that really hard to type ???

if you attract the curious, you can attract people with more professional use and even people able to contribute.

curious...but who ?
where are former users of Powerbasic ? ..why they don't contribute in o2..
some of them go to FB ...that are just few enthusiast
where are young programmers ...beginners ..i don't see them around any BASIC dialect
and etc..etc ...
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 06, 2022, 05:47:43 PM
sorry i use google translator and it might not translate to the context of what i want.
I didn't say that it's hard to create dll on O2, it was just the opposite, it's very easy to create an executable and dll on O2.

Just because you don't use it doesn't mean others don't.

I'm talking about curious people in general, I was curious, I bet you were also curious and ended up liking the O2.

yes, it has many dialects basic, power basic, purebasic,...
of course, many may find the free O2 the most attractive part, others may be afraid of the fact that O2 has a single developer and what happened with power basic , or even because it is not commercial, the developer changes everything from one hour to another.

It lacks advertising, it also lacks some tools and facilities as I said a competent ide, of course that's not the main thing, I think most of it goes by the existence of "Form", and even being able to use the windows tools directly in a native way.

the big issue with basic is the lack of standardization, I went to look at purebasic and it doesn't have "Then" in the "if", it uses "EndIf" instead of "End If",
Then you're going to tell me that it doesn't matter, that looking at these things is just because I'm lazy?
migrating from one to another is a very difficult task. so people switch to the ones that have as many tools as possible, or they just give up on basic and try to learn another syntax even though they don't like it.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 06, 2022, 06:21:51 PM
Thats why i prefer to stick - where possible - with the original Powerbasic-Syntax.
Just a minor change, for Labels i would prefer to have the ":" at the left side, because it makes the Parsing easier.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 06, 2022, 08:48:29 PM
Just because you don't use it doesn't mean others don't.
> whoever told you that, I made some dll.s in o2 and one for new lang called Dragon written in Java to test the GUI API
on windows 64bit
I'm talking about multidimensional arrays

> this single developer story is mantra I see few people out there complaining in loop all the time
which is pure speculation
yes, but there are people who are afraid to start using it and suddenly have to change

> migrating from FreeBasic or QB64 to Oxygen Basic is easy...as I know..I use them a lot, casual basic programmer will find out the difference in a day

to start using it can be easy, but to migrate internal projects it is not
imagine you with a project of thousands of lines, and out of nowhere having to remove all the Goto you put, or having to change the "If", or create macros for the matrices to work.
and even simple changes go through an adaptation process, when the person is used to a syntax they write without thinking much about it,
if they change syntax they take a long time to get to the same writing stage just thinking about the logic of what you want to do
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 06, 2022, 09:48:07 PM
one thing I think would be interesting would be syntax blocks.
being able to create blocks of specific syntax for each language, not being able to leave the specific syntax, so there would be no writing vices, you could easily use lines written for other languages without mixing and confusing the whole project.
it would be a point of reference for programmers of many other languages who want to migrate.
but unfortunately Charles already said that it is complicated to do that
syntax C
...
syntax end
syntax O2
...
syntax end
syntax powerB
...
syntax end
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 07, 2022, 08:35:52 AM
SYNTAX PB
....
END SYNTAX PB


;D

Would make it easy to migrate Projects.

Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 07, 2022, 11:06:29 AM
Heh ..sure Theo ..sure  ;D

Eduardo ...which other compiler support another syntax ???
as far as i know ..NO-ONE

is Powerbasic that one which have multidimensional arrays up to 64 dimensions  ;D

it is easiest to complain..as usual

tranlate large programs from one to another is always problematic
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 07, 2022, 11:49:25 AM
for Eduardo...if he not tried yet and bacause is easy to use AurelEdit06
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 07, 2022, 01:01:51 PM
I'm not complaining, well yes I am lol
I'm exposing a problem of existing basic languages.
there is simply no standard, each developer does what he wants even if he sells the project.
of course whoever got powerB first will find it better, whoever got VB6 first will find it the most comfortable.
I exposed the case of the multidimensional arrays of o2, of the "if" of purebasic, of goto, there are many other points, but the worst are variable declarations.

that makes basic not interesting for professional use, how many out there for the love of basic built their own basic interpreter or compiler but ended up dropping it?
you even have a website with some of them, and some very complete, even the QB64 that has "Inform", I don't know, but the developer seems to be Brazilian "not that it makes any difference"
with so many in love with Basic, if there was a primordial standard that facilitated the migration of projects, don't you think Basic wouldn't be much bigger?
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 07, 2022, 04:49:06 PM
could create a world agreement of Basic syntax, mainly in what refers to the declaration of variables, and basic functions.
so it would focus more on speed, implementations and tools, being able to migrate to the one that offers more tools, or cost benefit.
currently if you choose a basic compiler there is no way to migrate to another one that you think is better, simply because there are many different things in the syntax
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 08, 2022, 07:37:04 AM
you complain like a kid ...
my toy is not what is on picture   ;D

that is why we called them DIALECTS...but BASE  is same or similar
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 08, 2022, 10:23:27 AM

I see multidimensional arrays are a problem when migrating code to o2, so I will be implementing it. I've got it for static arrays but not resolved with the redims.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 08, 2022, 12:20:32 PM
First, I'm sorry Charles,
if you are going to implement it for my sake, you don't need to, my use of "Basic" is just as a hobby and I use vba even more, I use O2 just to assemble some DLLs, which for me doesn't even make much difference.
and I don't think that's why O2 has few users, I think it's because of the lack of support tools to draw attention as a more professional "IDE", and a form assembler for applications.
after all, what is the difference between "O2" and these others?
differences between them all have.

Zlatko, what would I be complaining about if I'm not even a professional programmer, it makes no difference in my usage,
I just stated a fact.
I'm just one more passionate about "BASIC" that I would like to see being used more professionally without just selling compilers.
from what you said, it can't even be called a "BASIC" language, and should be called so-and-so dialect.

Of course, you couldn't stay in the way the language was created, like having to write "REM" on every line of comment, or having to use line number for jumps "Goto", or "LET" to declare a variable.
but changing both the base, like "if then" without the "then", "endfor" instead of "next", using "end, endif,..." , tells me which code doesn't have "if".

it's like you go to another region of your country, and get cursed, and think it's a compliment because the person used a local dialect,
and you still say thank you.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 08, 2022, 03:05:23 PM
o why these differences are problematic in professional use.
a simple example in my case that is not even relevant in terms of dependency.
I have a code that I made at the beginning when I got vba, I didn't even know how to use public variables or functions, so I used "Gosub", nowadays I don't use it anymore, but the code works for me until today,
today I would do it better, yes, but it has a certain complexity that I don't dare to rewrite, it's not that big, I got to rewrite it in "O2", but I had problems with the hd at the time and lost it, so I left it aside since the from vba works fine.
look at the mess, well it works for me...

Private Sub Realoar_Click()
     If Limit = 1 Then MsgBox "Favor não Executar essa tarefa Nesta Planilha": Exit Sub
     If Quant <> "" And Quant < 3 Or Quant <> "" And Quant > 1000 Then MsgBox "Quantidade de Colunas impossivel de processar": GoTo Saida
     inicio
     '----------------------------------------------------------------------------------( Variaveis de Controle )-----------
     Dim Ddo As Variant, ddai As Long    '----------------------Dados
     Dim Tv As Long    ' ---------------------------------------Teste de Valores 1 = passa no teste  : 0 = Não passa
     Dim T As Long    '-----------------------------------Teste  de teste  0 = Negativo : 1 = Positivo
     Dim K As Long, f As Long
     ''-----------------------------------( ORIGEM )-----------------------------------------------------------
     Dim Op As Long, iCo As Long    '--------------------Direção prioritaria Op="0 = Coluna: 1 = Linha"; Controle Zig Zag Coluna iCo ="0 =Não faz: 1= Faz "
     Dim OLi As Long, OLf As Long, TLo As Long     '------------------------------------Linha inicial e final,"podem ser de quadrante"
     Dim Lio As Long, Lfo As Long    '------------------------------------Linha inicial e final,Total linhas da origem

     Dim OCi As Long, OCf As Long    '------------------------------------Coluna inicial e Final "podem ser quadrante"
     Dim Cio As Long, Cfo As Long, TCo As Long    '-------------Total de colunas ,Coluna inicial e Final "Ci e Cf"

     Dim Coi As Long, Loi As Long    ' ---------------------------------------Posição da celula "Coi = Coluna"   "Loi  = linha"
     Dim Zig As Long, Lig As Long    '-----------------------------------incremento  de Coluna e Linha

     Dim OqC As Long, OqL As Long    '-------------------------quantidade de Colunas e Linhas do quadrante
     Dim OqLi As Long, OqLf As Long    '------------------Linha inicial e final do quadrante
     Dim OqCi As Long, OqCf As Long    '-------------Coluna  inicial e final do quadrante

     '---------------------------------( DESTINO )-----------------------------------------------
     Dim Dp As Byte    '-----------------------------------------------------Direção prioritaria do Destino 0 = coluna: 1 = Linha
     Dim DLi As Long, DLf As Long, TLd As Long    '------------------------------------Linha inicial e final,Total linhas do Destino
     Dim Dci As Long, Dcf As Long    '------------------------------------------------Coluna inicial e Final

     Dim cdi As Long, Ldi As Long    ' ---------------------------------------PosiçãD Coluna Destino
     Dim Zag As Long, Lag As Long    '-----------------------------------incremento  de Coluna e Linha

     Dim DqC As Long, DqL As Long    '-------------------------quantidade de Colunas e Linhas do quadrante
     Dim DqLi As Long, DqLf As Long    '------------------Linha inicial e final do quadrante
     Dim DqCi As Long, DqCf As Long    '-------------Coluna  inicial e final do quadrante
     '---------------------------------------------------------------------------------------------------------( definição de variaveis )--------------------------

     '--------------------------------------------------------------------------------------------------------------
     'Plan Auxiliar
     PlanAtual = ActiveSheet.Name

     If Selecsetrel = True Then
          cs = Cells(10, Selection.Column).Value2

          cs = Cells(1, cs).Column
          If cs > 0 And cs < 10 Then
               Call Copia_SetorO(cs, Plan_list)
          Else
               MsgBox "Seleção não pertence a nenhum Setor"
               Exit Sub
          End If
     Else
          Call Copia_SetorO(De_1, Plan_list)
     End If

     If ExecAçõesOrigem Then
          Executa_Ação TxtbAçõesOrigem.Value
     End If

     Sheets("AUXIa").Select
     Call Colar_Setor(1, ColunO, Li, "AUXIa")


     If Relocatd Then crit = 0 Else crit = 3
     ti_o = Cells(1, Cells(14, 1).Value2).Column  '--------------------- primeira coluna da origem    ti
     ci_o = ti_o + crit    '------------------------------------------------------- primeira coluna da origem    ci
     Cq_O = Cells(1, Cells(18, 1).Value2).Column - ci_o + 1  '----------Total de Colunas da origem
     Gd = Cells(1, Cells(14, 2).Value).Column + crit   ' ----------------------Destino

     Li_O = Cells(Rows.COUNT, ci_o).End(xlUp).Row + 1


     'Range(Cells(1, Cells(14, 2).Value), ActiveCell.SpecialCells(xlLastCell)).ClearContents
     '--------------------------------------------------------------------------------------------------------------
     If Quant = "" Then Cq = Cq_O Else Cq = Quant    ': If Relocatd Then Cq = Cq + crit
     'Cq = Cq - crit

     OLi = Cells(3, ti_o).End(xlDown).Row - 1                                       '----------------------------define a primeira linha com dados da Origem
     OLf = Cells(Rows.COUNT, ti_o).End(xlUp).Row + 1    '                   ' -------------------define a ultima linha com dados da Origem
     TLo = OLf - OLi   ' ---------------------------------------------------------------------define total de linhas da Origem

     K = (TLo - 2) * Cq_O    '- 1 '--------------------------------------------------------------------Total de Celulas da origem
     OCi = ci_o - 1             ' -----------------------------------------------------Coluna inicial em NUMERO  ORIGEM
     OCf = OCi + Cq_O + 1  ' ------------------------------------------Coluna Final em NUMERO  ORIGEM
     TCo = Cq_O + 1   '--------------------------------------------------------------------Total de Colunas da origem
     Dci = Gd - 1      '--------------------------------------------------------------------        'Coluna inicial em numero  DESTINO  "AuxB"
     Dcf = Dci + Cq + 1                                       ' Coluna Final em NUMERO  DESTINO
     TLd = (Int(TLo / Cq) * Cq_O) + Int(TLo Mod Cq)    'ns            ' QUANTIDADE DE LINHAS DO Destino
     dcdo = Dci - OCi    'diferença coluna inicial da origem para a coluna inicial do destino
     'MsgBox Cq_O

     If OLf - TLd < Li Then
          OLi = OLi + ((Li + (OLf - TLd) * -1) / ((Cq_O - 1) / Cq))

          TLo = Range(Cells(OLi, ci_o), Cells(OLf, ci_o)).Rows.COUNT       ' ---------------define total de linhas da Origem
          K = (TLo - 2) * Cq_O   '--------------------------------------------------------------------Total de Celulas da origem
          TLd = (Int(TLo / Cq) * Cq_O) + Int(TLo Mod Cq)    'ns            ' QUANTIDADE DE LINHAS DO Destino
     End If

     '--------------------------------------------------------
     DLi = OLi - 12                                                       'Linha inicial do Destino
     DLf = OLi + TLd - 1                                            'Linha Final do Destino
     Cio = OCi  ' -<<----- ( Coluna inicial Origem )--
     Cfo = OCf    'Oci + Cq_O 'Ocf ' -<<----- ( Coluna Final Origem )--

     '-----------------------------( DESTINO)------------
     Lag = 1    '  ------------------------------------------  incremento Linha de Destino
     If Alinhar_Baixo = True Then Lag = Lag * -1: DLi = OLf: DLf = DLi - TLd   '- 1)

     Ldi = DLi:     ' ------------------------------------------------Posição Linha Destino
     If Dinvert_L = True Then DLi = DLf: DLf = Ldi: Ldi = DLi: Lag = Lag * -1    'inverte linha

     Zag = 1  ' -----------------------------------------------------   incremento Coluna de Destino
     If Dinvert_C = True Then Zag = Zag * -1
     If DdpL = True And Dquadante_L = False Then Dp = 1: Dci = Dci + Zag: Dcf = Dcf + Zag Else Dp = 0: Ldi = Ldi + Lag    '-----0 = coluna: 1 = Linha
     cdi = Dci
     If Dinvert_C = True Then Dci = Dcf: Dcf = cdi: cdi = Dci    'inverte coluna
     If DdpL = True And Dquadante_L = True Then Dp = 1: Ldi = Ldi + Lag: cdi = cdi + Zag

     If Dquadante_L = True Then
          If DQuatL <> "" And DQuatL < TLd And DQuatL > 0 Then DqL = DQuatL Else DqL = Cq_O
          DLf = DLi + ((DqL + 1) * Lag)    '----------------------------------( Linha de baixo )----------------------------
          DqL = DqL * Lag: Ldi = DLi
          If Dinvq_L = True Then DLi = DLf: DLf = Ldi: Ldi = DLi: Lag = Lag * -1
          If Dp = 0 Then Ldi = Ldi + Lag
     End If

     If Dquadante_C = True Then
     End If
     Loi = 23
     '----------------------------------------------------------( ORIGEM )------------
     Lig = 1  '    incremento Coluna de origem
     Loi = OLi:     ' Posição Linha origem

     If Oinvert_L = True Then OLi = OLf: OLf = Loi: Loi = OLi: Lig = -1    'inverte linha de cima para baixo
     Zig = 1  '    incremento Coluna de origem
     If Oinvert_C = True Then Zig = Zig * -1:     'Cio = Cfo: Cfo = Oci: iCo = 1 Else iCo = 0

     If OdpL = True And Oquadante_L = False Then Op = 1: OCi = OCi + Zig: OCf = OCf + Zig Else Op = 0: Loi = Loi + Lig    'Linha com prioridade
     Coi = OCi
     If Oinvert_C = True Then OCi = OCf: OCf = Coi: Coi = OCi:     'inverte coluna
     If OdpL = True And Oquadante_L = True Then Op = 1: Loi = Loi + Lig: Coi = Coi + Zig

     If Oquadante_L = True Then
          If OQuatL <> "" And OQuatL < TLo And OQuatL > 0 Then OqL = OQuatL Else OqL = Cq
          OLf = OLi + ((OqL + 1) * Lig)    '----------------------------------( Linha de baixo )----------------------------
          OqL = OqL * Lig: Loi = OLi
          If Oinvq_L = True Then OLi = OLf: OLf = Loi: Loi = OLi: Lig = Lig * -1
          If Op = 0 Then Loi = Loi + Lig
     End If

     If Oquadante_C = True Then
          If OQuatC <> "" And OQuatC < Cq_O And OQuatC > 0 Then OqC = OQuatC Else OqC = Cq_O    ': MsgBox "Valo de quadrante  entre " & "1 " & TLo / 2
          ' If Op = 0 Then OLi = OLi - 1
          If Oinvq_C = True Then iCo = 1 Else iCqo = 0   '-<<----( controle invert )--
          'If iCo = 1 Then: Cio = Cfo: Cfo = Oci
          OCf = OCi + ((OqC + 1) * Zig)    '----------------------------------( coluna Esquerda )----------------------------
          OqC = OqC * Zig: Coi = OCi
          If iCqo = 1 Then OCi = OCf: OCf = Coi: Coi = OCi: Zig = Zig * -1
          If Op = 1 Then Coi = Coi + Zig
     End If
     '------------------------------extras
     If invert69 = True Then t69 = 1 Else t69 = 0
     If invertvalMax.Value <> "" Then tmax = invertvalMax.Value Else tmax = 0

     '-----------------------------( LOOP )----------------------------------------
     For w = 1 To K
          'Origem --( Leitura )--

          If Op = 0 Then GoSub OCoL: If T = 1 Then T = 0: GoSub OLin
          If Op = 1 Then GoSub OLin: If T = 1 Then T = 0: GoSub OCoL
          Ddo = Cells(Loi, Coi).Value2    '= w  '
          'Destino --(Escrita )--

          'If invertValTbx = True Then If IsNumeric(Ddo) And Ddo <> "" Then Ddo = invertVal(Ddo, t69, tmax)
          ' pp = 0
          '        If ReTr_M = False Then
          '        Else
          '            If ReTr_Ec = True Then If Ddo = Cells(Loi - 1, Coi - 1).Value2 Then pp = 1
          '            If ReTr_Mc = True Then If Ddo = Cells(Loi - 1, Coi).Value2 Then pp = 1
          '            If ReTr_Dc = True Then If Ddo = Cells(Loi - 1, Coi + 1).Value2 Then pp = 1
          '            If ReTr_Eb = True Then If Ddo = Cells(Loi + 1, Coi - 1).Value2 Then pp = 1
          '            If ReTr_Mb = True Then If Ddo = Cells(Loi + 1, Coi).Value2 Then pp = 1
          '            If ReTr_Db = True Then If Ddo = Cells(Loi + 1, Coi + 1).Value2 Then pp = 1
          '        End If
          '  If Ddo <> "" Then
          ' If pp = 0 Then
          If Dp = 0 Then GoSub DCoL: If T = 1 Then T = 0: GoSub DLin
          If Dp = 1 Then GoSub DLin: If T = 1 Then T = 0: GoSub DCoL
          'If IsNumeric(Ddo) And Ddo <> "" Then Ddo = Ddo + (Cdi - (Coi + dcdo))
          Cells(Ldi, cdi).Value2 = Ddo   'w
          ' End If
          '   End If
     Next
     ''-------------------------------------------------------------( Fim do loop )----
     GoTo Saida
     '----------------------------( ORIGEM )------------
OLin:
     If Op = 0 Then
          If T = 1 Then Loi = Loi + Lig
          If OZig_L = False Then
               If Loi = OLf Then
                    If Oquadante_L = True Then OLf = OLf + OqL: OLi = OLi + OqL
                    Loi = OLi + Lig
               End If
          Else
               If Loi = OLi Or Loi = OLf Then
                    If Oquadante_L = True Then OLf = OLf + OqL: OLi = OLi + OqL: Loi = Loi + OqL
                    Lig = Lig * -1: Loi = Loi + Lig
               End If
          End If
     End If

     If Op = 1 Then
          T = 0: Loi = Loi + Lig

          If OZig_L = False Then
               If Loi = OLf Then
                    T = 1
                    If Oquadante_L = True Then GoSub OCoL: If T = 1 Then OLf = OLf + OqL: OLi = OLi + OqL: T = 0
                    Loi = OLi + Lig
               End If
          Else

               If Loi = OLi Or Loi = OLf Then
                    T = 1
                    If Oquadante_L = True Then GoSub OCoL: If T = 1 Then OLf = OLf + OqL: OLi = OLi + OqL: T = 0: Loi = Loi + OqL
                    '  If OZig_LN = 4 Then
                    Lig = Lig * -1: Loi = Loi + Lig
                    '    Else
                    ' OZig_LN = OZig_LN + 1
                    '  End If
               End If
          End If
     End If
     Return

OCoL:          '-----------------------------------( Controle de colunas )----------------------------------
     T = 0: Coi = Coi + Zig
     If Op = 0 Then
          If OZig_C = False Then
               If Coi = OCf Then
                    T = 1
                    GoSub OLin:
                    Coi = OCi + Zig:
               End If
          Else
               If Coi = OCi Or Coi = OCf Then
                    T = 1
                    GoSub OLin:
                    Zig = Zig * -1: Coi = Coi + Zig:
               End If
          End If
     End If
     If Op = 1 Then  'If T = 1 Then Coi = Coi + Zig
          If OZig_C = False Then
               If Coi = OCf Then
                    Coi = OCi + Zig: T = 1
               End If
          Else
               If Coi = OCi Or Coi = OCf Then
                    Zig = Zig * -1: Coi = Coi + Zig: T = 1
               End If
          End If
     End If
     Return

     '------------------------------------------------------( DESTINO )-----------------------------------
DLin:
     If Dp = 0 Then
          If T = 1 Then Ldi = Ldi + Lag
          If DZig_L = False Then
               If Ldi = DLf Then
                    If Dquadante_L = True Then DLf = DLf + DqL: DLi = DLi + DqL
                    Ldi = DLi + Lag
               End If
          Else
               If Ldi = DLi Or Ldi = DLf Then
                    If Dquadante_L = True Then DLf = DLf + DqL: DLi = DLi + DqL: Ldi = Ldi + DqL
                    Lag = Lag * -1: Ldi = Ldi + Lag
               End If
          End If
     End If

     If Dp = 1 Then
          T = 0: Ldi = Ldi + Lag
          If DZig_L = False Then
               If Ldi = DLf Then
                    T = 1
                    If Dquadante_L = True Then GoSub DCoL: If T = 1 Then DLf = DLf + DqL: DLi = DLi + DqL: T = 0
                    Ldi = DLi + Lag
               End If
          Else
               If Ldi = DLi Or Ldi = DLf Then
                    T = 1
                    If Dquadante_L = True Then GoSub DCoL: If T = 1 Then DLf = DLf + DqL: DLi = DLi + DqL: T = 0: Ldi = Ldi + DqL
                    Lag = Lag * -1: Ldi = Ldi + Lag
               End If
          End If
     End If
     Return

DCoL:
     T = 0: cdi = cdi + Zag
     If Dp = 0 Then
          If DZig_C = False Then
               If cdi = Dcf Then
                    T = 1: GoSub DLin:
                    cdi = Dci + Zag:
               End If
          Else
               If cdi = Dci Or cdi = Dcf Then
                    T = 1
                    GoSub DLin:
                    Zag = -Zag: cdi = cdi + Zag:
               End If
          End If
     End If

     If Dp = 1 Then
          If DZig_C = False Then
               If cdi = Dcf Then
                    cdi = Dci + Zag: T = 1
               End If
          Else
               If cdi = Dci Or cdi = Dcf Then
                    Zag = -Zag: cdi = cdi + Zag: T = 1
               End If
          End If
     End If
     Return

     '***************************************Fim
Saida:
     Dim Dest As Variant

     If Para_2.Value = "" Then Dest = De_1.Value Else Dest = Para_2.Value
     If Selecsetrel = True And Para_2.Value = "" Then Dest = cs



     If Relocatd Then Cq = Cq - crit Else Cq = Cq + 3
     C = Cells(1, Cells(14, 2).Value2).Column
     If SetTud = True Then
          If Relocatd = False Then
               ColunO = Range(Cells(14, 1).Value2 & Li, Cells(15, 1).Value2 & lf).Value2
               Range(Cells(14, 2).Value2 & Li, Cells(15, 2).Value2 & lf).Value2 = ColunO
          End If
          ColunO = Range(Cells(Li, C), Cells(lf, C + Cq)).Value2
     Else
          ColunO = Range(Cells(Li, C + crit), Cells(lf, C + Cq)).Value2
     End If

     'Range(Cells(1, ti_o), ActiveCell.SpecialCells(xlLastCell)).ClearContents
     'Sheets("AUXIa").
     Range("A23", ActiveCell.SpecialCells(xlLastCell)).Clear    'ClearContents
     Sheets(PlanAtual).Select
     If SetTud Or Relocatd Then
          Call Colar_Setor(Dest, ColunO)
     Else
          CqD = Cq - crit
          Call SetorL(Dest)
          Call ColunasN(CqD)
          Range(Ci & Li, Cf & lf) = ColunO
     End If

     Final
End Sub
''-------------------------------------


but I still use "goto" a lot,
imagine a situation like this in a professional project "of course a professional project wouldn't have a code like that", and that has thousands of lines, changing the name of some word can be easy, but lack of functions, or differences in variables can be fatal.
many languages look like "C", but they are not called "C" language
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 09, 2022, 07:40:06 AM
Quote from: Charles Pegge on September 08, 2022, 10:23:27 AM

I see multidimensional arrays are a problem when migrating code to o2, so I will be implementing it. I've got it for static arrays but not resolved with the redims.

If Macros work, you can still implement it like this "Under the hood" and give End users the normal "DIM [AT] (x,y,z) Syntax".
If these Arrays will be able to be re-dimed without losing content, it will be an advantage even over Powerbasic.
Where only 1 dimensiponal arrays can be REDIMED without losing content (and i am not sure this really works with all Datatypes).

Datatypes and Array (http://www.jose.it-berater.org/smfforum/index.php?topic=5687.msg24626#msg24626) are a critical Part of Basic and here is the Part where the Programmer can save a lot of time if the language designer invested a lot of time.

Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 09, 2022, 07:43:29 AM
Quoteyou don't need to, my use of "Basic" is just as a hobby and I use vba even more,

so why you then moaning and complain ?
ahh you want to have code for easy translation ..give me a break :(

Also i don't see what is wrong with different syntax..every basic have something different.
but most of syntax is based on old MS QuickBasic.

QuoteI'm not even a professional programmer,
i am not proffesional programmer too..so what? ...
then stop talking about things you don't need ... ???

there is no need for any multi-dimensional arrays ..especially if that things broke other part of Oxygen basic
which work much better than is other compilers.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 09, 2022, 03:40:28 PM
I think you are taking the matter personally because of your passion for "O2"
I said in general, there was only the case that the "o2" was multidimensional arrays.
you don't see in "c" people having to change dialects when going from a "C" to another "C".
and it's precisely because you don't use programming in a professional way that you don't see problems in these differences, so you should know that for me these differences aren't problematic either.
but, how are professionals going to adopt a language like that without any standard?
how can a company hire basic programmers, and when they work together, what if each one learned a different "basic"?

Seriously, you just saw this wrong in this code? lol
Simply put, that's all wrong, despite working.
but it was an example that in large and old projects there is always a section that no one wants to touch, but the project depends on it.
I ask you, in a case like this, is there a way to switch from one "basic" to another?

but well, this discussion won't even lead to anything,
as I said, it makes no difference to me, even without multidimensional arrays I'll continue using O2, I just pointed out a characteristic of "basic" and not exactly of "O2"
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 10, 2022, 05:22:42 PM
why am i contradictory?
you asked why people are leaving Powerbasic and going to freebasic, I talked about why, there is simply more baggage and tools.
yes I prefer the O2 too, but a lot of these people want something for work, so a good IDE and a form builder are important.
about AurelEdit, see that it is not announced as a standard ide, nor is it even announced for valid use with O2, it is a project that, as far as I know, was not even started for O2, but it has been adapted for O2 later, but even so, it is not announced next to the O2, only those who have been here the longest know that it exists as an "ide" for the O2.

if the "basic" were all the same, the tools could be reused, you could try different compilers, different ideas and all the form assemblers you have for Basic, and that would certainly make more people try to use O2

an example is thinbasic, it has more users than O2, it even has O2 built in, O2 is much faster than thinbasic, but what does thin basic have that o2 doesn't have?
tools ,
Of course, O2 doesn't have collaborators like thinbasic, but O2 also had many changes, some because Charles kept meeting demands, some interesting, others just for personal taste.
It works for me, it works for you too.
but is it for everyone?

looks like you're helping with the O2 documentation, it's also an important step, maybe the most important, and for that I also thank you, as well as charles "of course, more to charles , lol "
but seriously, this discussion with me is not going to lead anywhere, I'm just a fly here, my considerations are the same thing as nothing.
it would be valid if I had the ability to help in something and I was doing so, but as you can see, even in vba I'm incompetent, so you can ignore what I write
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 10, 2022, 10:55:54 PM
Quoteabout AurelEdit, see that it is not announced as a standard ide, nor is it even announced for valid use with O2, it is a project that, as far as I know, was not even started for O2, but it has been adapted for O2 later, but even so, it is not announced next to the O2, only those who have been here the longest know that it exists as an "ide" for the O2.

first of all AurelEdit is completely written in o2..
it is made for Oxygen basic in first place and yes it is valid
what i can is to publish it on sourceForge
it is not "announced as a standard ide " probably because Charles have something different on his mind
and i never asked him to announce it as standard IDE for o2

I asked him many times why he don't include it under Scintilla projects?
but looks to me that he ignored that and leave old example called AsciEdit there ...hmm

for thinBasic ..it must be a joke ....did you recently visit tB forum
..there is maybe one or two members and one or two visitors
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 10, 2022, 11:43:12 PM
being written in O2 does not mean that it was written to be used with O2, the O2 itself was initially made in freebasic, so I prefer o2, should I use freebasic just because o2 was made with it?
after it was completely compiled by o2 itself.
ok thinbasic has been weak lately, but tell me which basic language is booming, from what I saw there was even a recent update in the "thinAir" ide, (at this moment 245 visitors), particularly I don't use it, I downloaded it but I don't use it, I also downloaded it the freebasic, but I left it aside.
was AurelEdit made by you? I didn't even know, it's getting better.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 11, 2022, 08:17:43 AM
no it was made by you..!
;D
Title: Re: O2 Arrays / BASIC Standardization
Post by: Bernard Kunzy on September 11, 2022, 09:35:20 AM
Eduardo,

I agree, that there is no standard BASIC syntax, and this won't help to gain new users, except in the hobbyist sphere.


Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 11, 2022, 06:51:50 PM
I think a standard BASIC should definitely include gosub and goto. They are most valuable for occasional use, o2 won't be dropping them any time soon.

I've now coded both static and redimable multidimensional arrays but it will need a period of careful testing. We can set the index-base and select column-major order as in PowerBasic, or row-major order (default) as in C and FreeBasic.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 11, 2022, 11:35:15 PM
Charles
I think people think that goto and gosub will bring back the spaghetti code.
forget that at the time it was the only way to have independent sections, there is still the case that nowadays the line number is no longer used to indicate where it is jumping.
occasionally they help to have faster and smaller code, in my case I prefer using conditional jumps than using conditional loops.
gosub sometimes helps me to define the logic of what I'm writing but then I write without it.

well remembered on the basis of multidimensional matrices, VB'a also uses column order,
having the selection option will help you migrate projects

but seriously, this default in basic made such a mess that it was practically impossible to migrate between basic
see the simple case of "IF", which code does not have "IF"
in one there is no "then", each one has a way to end "End, endif, end if", I think I've seen one there that is called basic but uses ")" to end the "IF"
has its own MS that made a kind of successor of VB , but uses "endfor" instead of "next"

it would be good to have an agreement on the syntax of the base between so many developers, what could be added to standardize the various existing basics would bring a lot of strength to the language, it would help even those who market it,
like, the ones that use the " if " without the " then ", if you added the option to use the " then " for example, whoever took the " Goto " put it for default reason " uses who wants ",
you have done a great job in this regard, it's a pity and the others just think about their personal taste, or their pocket and create a dialect that those who adopt cannot easily go to another one.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 11, 2022, 11:47:41 PM
what you talking about ?

then exists in o2 keywords....but i hate to use it
it sucks if you ask me

every REAL language have GOTO
GOSUB is nice and o2 have it ...so please stop "with wall of text about nothing"

then? OMG
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 12, 2022, 12:21:03 AM
the subject is standard from "BASIC",
it's not what the O2 has or doesn't have, nor what you or I like to use.

on my shelf there are 2 books that I thought would be a bad read, so I ignored them, and never picked them up to read, you have the right to do the same about what I write.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Johan Klassen on September 12, 2022, 06:09:39 PM
hello Eduardo Jorge :)
I disagree that gosub's and goto's would inevitably lead to spaghetti code, gososub' are ok if the programmer self-imposes some basic restrictions
1: clearly delineate the start and end of the routine
2: only 1 entry point
3: don't use goto to jump outside the routine

Quote
on my shelf there are 2 books that I thought would be a bad read, so I ignored them, and never picked them up to read, you have the right to do the same about what I write.
I agree, I do that with Zlatko Vid aka aurel posts, his posts are usually crude and sometimes rude but mot of the time nonsense
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 12, 2022, 08:12:15 PM
wait a moment to you two...

what is rude,crude or non-sense?
I am user of o2 more than 10 years and i know what is what in general.

so ..i might be stupid but i made very unique
in ay sense
token interpreter in Oxygen Basic without anyone help
without UDT,without multi-dimensional arrays, without OOP or any other
similar fancy things  >:(
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 13, 2022, 03:04:20 AM
Zlatko
no one is doubting your ability.
but the inclusion of multidimensional arrays doesn't denigrate the "O2", it just makes it more practical to use.

just take things more in sport, we are exchanging ideas, or just chatting, not only about "O2" and not only about personal tastes, but about what can bring more visibility about "O2" and about "BASIC ", even if it doesn't lead to anything, it helps us to calm our sorrows

I didn't know you were aurel, so I had no way of knowing that you had written aureledit, I even praised your work and you came to me with irony saying that I had written it,
I don't know if my words had a different meaning using the translator, but I had already exposed that fact and I even apologized for it.
this discussion is only getting in the way of Chales' excellent work.
about "then" , I just exposed the fact that one has it and the other doesn't, "O2" allows both ways of writing and that makes it easier to use ready-made codes.

PEACE.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 13, 2022, 05:11:00 PM
Johan Klassen

"goto" and "gosub" created spaghetti code when they were the only ways to structure routines.
"gosub" nowadays is just to avoid creating functions for small routines.
already "goto" I use a lot, "IF" condition "Then" "Goto"
and nowadays the numbers of lines are not used anymore, the labels can be very descriptive, much more than the names of functions.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 13, 2022, 05:13:43 PM
Charles,
first... good morning, good afternoon, good night
I saw that you posted a new version of O2.
Can you tell what's different about this version?
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 13, 2022, 09:07:50 PM
Hi Eduardo,

This version supports static &  dynamic multidimensional arrays, and endfor/end for endselect for consistency :)

I am also trying  overlay, which is like redim, but without memory allocation. You supply the base address instead.

row-major order is the default but can be set using #majorminor
column-major order is set with #minormajor
These are global switches, and modules have to be aware of them, as well as the indexbase

There is some more testing to be done using the arrays but I have just refreshed P7

https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P7.zip
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 13, 2022, 10:55:23 PM
I had already downloaded P7, but I downloaded it again.
nice, O2 at least in the basic structure is compatible with most existing "basic" dialects
at least it's easier to write a keyword that changes the base of an array than to rewrite all the code in those arrays.
I wonder how difficult this is to implement to the point that other developers don't include it for better standardization.
of course the best would be just a pattern to not have messy codes, but as it is already like this the best would be to include all variants in all basic
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 13, 2022, 11:37:33 PM
I thought "EndFor" was just that basic thing from ms, I even thought "why put that?", but I searched here and saw other places that use it
but charles, in his personal, really personal view...
which would be the best way to go, because if you keep adding all possible variants, there will be no end.
in my humble opinion, you should just work on the base of the O2, to stay fixed, just change the speed issue and eliminate errors,
on that basis, there would be no more changes, neither in the type of variables nor in the functions, and from then on, just add things that you think can be useful
so whoever gets the O2 won't be afraid of you changing something, and the changes would only be to put new features, although I think you're already doing that
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 14, 2022, 06:14:11 AM
Memory Allocation and Datatypes are - besides Constructs like Loops and If/else/endif (and such), are the key-features of a programming language.

While at "Loops and IF/ENDIF" Constructs, the programming Languages can not make much of a difference,
Powerbasic tried with CHOOSE$ which was not often used, the available Datatypes, - and what you can do with these
- make the difference.

Based on these features, all other things can be implemented later in a Wrapper Style.
Or in short: The language should deliver all the stuff that can not be added later "as Includes".
This is mostly not so much: IF, ENDIF, PROCEDURE, MACRO etc.

Anything that can easily be added later "as a module" or "as a include" must not not be hardcoded but can be added as a Include.
From whoever.

Besides that its important that the user is able to build up own Libraries with his most used Subprogramms.
In Powerbasic it was possible to build Libraries.

But when a Procedure needed an Entry in the "Sub Main()" or in "GLOBAL" it could not easily be done.
Also you could not put Stuff that will create a GUI into a Library because you could not "pre-formulate" the Code for the
Message-Que. In a way that you could build it up using Components from a Library".

I don't know if this could have been solved using Jose's GUI Library, but generally this is where Powerbasic failed.
So lets see if we can find way to make it better in the future.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Karen Zibowski on September 14, 2022, 06:35:21 AM
 Hi
With all due respect, I do believe that GOTO and GOSUB are intrinsic statements of BASIC,  ever since
BASIC was invented,  I do appreciate that these statements be retained in O2  ( OxygenBasic)
Hope Charles is understanding on this aspect and Thank you so much

Karen
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 14, 2022, 06:06:56 PM
Charles
wouldn't you be able to put a "TXT" with the changes you make?
or already have it, where ?
so it should be easier since you would be documenting each modification,
and you wouldn't need to explain the changes, because it would already be in the file we downloaded.
  and someone else could help with the O2 documentation later by following this text file.
well, I don't know if it's easier or not, you have to decide what's best
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 14, 2022, 06:21:14 PM
Charles
sorry i found it now
OxygenBasic\inf
oxyLog.txt
but a description and an example of use would be good
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 14, 2022, 09:28:28 PM
Quote from: Charles Pegge on September 11, 2022, 06:51:50 PM
I think a standard BASIC should definitely include gosub and goto. They are most valuable for occasional use, o2 won't be dropping them any time soon.

I've now coded both static and redimable multidimensional arrays but it will need a period of careful testing. We can set the index-base and select column-major order as in PowerBasic, or row-major order (default) as in C and FreeBasic.

Generally a GOSUB will just compile into a JSR and a RET ... means single ASM-Mnemonics.
This is the base for efficient programming. I am using GOSUB very often.
One of the reasons, why i avoid Purebasic is, that due to the malformed Compiler Constructions,
there is no real GOSUB and RETURN that can compile into a single Instruction.
Must say that I am also from a Time where any CPU Cycle was worth counting.
Let me add that i registered today a new user from Mexico, name "Attila" and he also writes that he likes to count CPU Cycles and therefore wants to join the O2 Userbase. He writes:

". I still program sometimes for fun, I want to test ideas and algorithms in a few lines of code w/o having to use a RAD environment and all the bloatware associated whit it. Hence I'm researching alternatives, interpreted languages doesn't interest me too much, having worked with stuff where every byte and CPU cycle counts, it's hard to change habits...lol."

Lets see if we can welcome him here soon.

Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 17, 2022, 08:00:24 PM
Charles,
I noticed that you put the changes in oxyLog.txt
and the tests in testlog3.o2bas.
  would it be possible to do this for the released version?
I believe that this way it would be easier to locate and know what was modified for each of the versions separately,
claor is not to make the previous ones, but for each version released from now on, a separate file.

  and the tests you do would already serve as an example parameter, being necessary to put only some description for some things,
only a single file would be needed, the test.

20:23 06/09/2022 Implement multidimensional arrays (decl.inc expr.inc)
indexbase 0
int i,j
dim int a[99,9]
'#recordof a
'#show a=a[i+99,j]
'#show a=a[3,4]
'
'#show a=a[4]
'#show a=a[i]
'#show a=a[i+4]
*/

Of course I could be talking a lot of nonsense, if that's the case just ignore it, lol

I'm currently building a test macro
I don't know how I would get by without the "GOTO"


d2 = 0
          For D = -Lmin To tdS - Lmax 
               For C = 0 To 9
                    Pteste(C) = False
               Next
               '...
               For p = 0 To 9
                    If Ats_(p) Then
                         n = Dez_Ar(D + Lin_(p))
                         If dez_(p, n) Then   
                              Pteste(p) = True
                         End If
                    End If
               Next
               '...
               For p = 0 To 9
                    n = 0
                    If AtsP_(p) Then
                         '......................................
                         For C = 0 To 9
                              If Ats_(C) Then
                                   If Pteste(C) Then
                                        If Col_cc(p, C) Then n = n + 1
                                   End If
                              End If
                         Next
                         '......................................
                         If n < Min_(p) Then GoTo pulaDezena
                         '......................................
                    End If
               Next
               '...
               sd = SotAR(D)
               If saidaSotAR(d2) < sd Then
                    d2 = d2 + 1
                    saidaSotAR(d2) = sd
               End If

               '...
pulaDezena:
          Next
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 17, 2022, 09:55:27 PM
Hi Eduardo,

My Broadband Internet has been very unstable over the last few days, so I've been producing more frequent updates, just in case I am cut-off for a prolonged period. The TestLog entries are primarily for functional testing. They give an indication of syntax, but they are not ideal examples. That will take time.

The latest 050P8 implements:

indexbase  0 or 1 as previous
#majorminor  row-major order
#minormajor  column-major order
dims  number of dimensions
elements  total number of elements
lbound  base elements (currently the same as indexbase)
ubound  max element for each dimension (adjusted with indexbase)
scaler  the multiplier used on each dimension to calculate the element location

UPDATE:
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P8.zip

testlog:

'17/09/2022
'multidim check
uses console
'#minormajor
'dim int d(1,2,3,4,5)
'redim int d(1,2,3,4,5)
redim int d(5,4,3,2,1)
redim int d(10,10,10,10,10)
d(1,2,1,4,5)=123
print d(1,2,1,4,5) cr
'redim int d(1,2,3,4,5)
'redim int d(60,2)
int i
for i=1 to dims(d)
  print ubound(d,i) tab scaler(d,i) cr
next
print cr

int *dd=@d
'for i=1 to ubound(d)
'print i tab dd(i) cr
'pos 80 == 0*120+1*60+0*20+3*5+1*4+indexbase
'next
wait

/*
'16/10/2022
'elements, dims
'ubound, lbound
'arwd
int cc,ee
'#show "t.txt"{
dim int d(1,2,3,4,5)
'cc=elements(d)
'ee= dims(d)
'void_ hah,hah
'indexbase 0
cc=lbound(d)
ee=ubound(d)
'}
'
'#recordof swap
'#recordof scaler
'print cc "   " ee
int i=1
'print dims(d)
'print elements(d)
'
for i=1 to dims(d)
  print " " scaler(d,i)
  'print " " lbound(d,i)
  'print " " ubound(d,i)
next
print ubound(d) " ok"
*/

Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 17, 2022, 10:30:39 PM
Hi Theo,

Iam always looking for opportunities to reduce OxygenBasics core-code! Quite a large part of the language is soft-coded in macros, which can be found in inc/self/lang.inc.

Here are familiar BASIC words which do not need to be core-coded:


true  18 -1
false 18 0
use 18 include once
uses 18 include once
using 18 include once
global 18 dim static 'global is deprecated
lobyte 18 ((%1) and 0xff)
loword 18 ((%1) and 0xffff)
hibyte 18 (((%1)>>8) and 0xff)
hiword 18 (((%1)>>16) and 0xffff)
chr_ 18 mid_
wchr_ 18 mid_


Most of the maths functions are directly coded into FPU Asm:

abs 17 fabs
acos 17 fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fxch : fpatan
asin 17 fld st0 : fmul st0 : fld1 : fsubp st1,st0 : fchs : fsqrt : fpatan
atan  17 fpatan
atn 17 fld1 : fpatan
cos 17 fcos
deg 17 fldpi : fdivp st1 : |sp -8 : mov [rsp],180 : fimul dword [rsp] : |sp 8
frac 17 fld1 : fxch : fprem : fstp st1
hypot 17 fmul st0 : fxch : fmul st0 : faddp st1 : fsqrt
lin 17 fldln2 : fxch : fyl2x
...

Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on September 18, 2022, 06:04:42 AM
You know that Bob treated DWORD often like FP to prevent Overflow.
Thats why LONGS in PB were originally faster then DWORDS.
How is your position on DWORD vs. LONG ?
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 18, 2022, 08:54:16 AM
Both longs and dwords are normally processed in the CPU, but an expression containing a '/' float division will be processed in the FPU.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 19, 2022, 11:56:30 PM
Quote from: Charles Pegge on September 17, 2022, 09:55:27 PM
The TestLog entries are primarily for functional testing. They give an indication of syntax, but they are not ideal examples. That will take time.

it may be insufficient, but it's better than nothing, it would be more like a starting point for testing.
it would also be interesting if you put the tests in some selection structure
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 22, 2022, 06:36:26 PM
Charles, I think a quick and simple solution for O2 would be to start from scratch.
a new name, you see what is more basic, stable and simple and start from there.
and only make changes that don't change the functionality for things written in older versions, only add and never take away, so it's important to start with only important and functional things.
if you can have O2 in parallel as a test version only, everything that is added or modified is done only on O2 and after the test period add it to the new project.

I say this because of the big changes that the O2 had, harming the understanding of what works or doesn't work.
someone new can take the o2 to test and paste something they find here on the forum and it just doesn't work because it was written in a previous version, myself these days I took something simple to test and it only had errors, imagine someone new who doesn't know of the changes that the O2 had.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 23, 2022, 01:36:32 AM
charles, I don't know how far this is possible, or if it is possible.
but an idea would be to take advantage of an existing "basic" platform that is open source, in this new project, maybe freebasic itself.
use as a syntax base, thus having what already exists for freebasic,
of course it would only be as a base, but add the facilities that you have already added in O2.
Of course I'm just talking as an idea, I don't even know how far this is really possible or viable.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 23, 2022, 07:15:07 PM
Hi Eduardo,

My main interest is in producing clear easy-to-read code efficiently. I am not particularly interested in classical BASIC and its redundant syntactical forms.

Nor do I have any ambitions to 'mass-market' o2. Anyone is welcome to make use of it for their own purposes.

The future is unclear, but in the long-term we may see programming delegated entirely to AI, and arguments about different languages become irrelevant.

Self-compiling is a very interesting paradigm. The circularity of it refines the code structure, and I enjoy removing redundant code as much as creating new code :)
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on September 23, 2022, 08:03:47 PM
Good answer ...i like it!
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on September 24, 2022, 08:01:29 AM
Quote from: Zlatko Vid on September 23, 2022, 08:03:47 PM
Good answer ...i like it!

yes, a good answer,
but do you remember how this discussion started?
It was with you talking about why people weren't coming to the O2.
and with that some theories were emerging, until arriving at the ideas of solutions.
and one of the solutions would be a new name to disassociate O2 from an unstable project that changes something all the time

but if the O2 is a personal project of charles, as a hobby, none of this discussion makes sense.
as I had reported, my use is amateur and I use O2 for the ease of creating DLLs for excel vba, and I do it sporadically.
so for me what charles does on the O2 makes little difference in my use, but for someone who wants something more stable it does make a difference.

Charles, about AI programming, there are a couple of factors about it,
the logical ideas of what you want to program, it is not always easy to define these ideas in a logic, it is like mathematics that is a language, everything has its place of importance, and the Ia themselves need to be programmed.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on September 25, 2022, 11:03:06 AM
Hi Eduardo,

Please let me know when you encounter any broken code. I monitor the demo code frequently but it takes time to cover hundreds of examples.

Multidimensional array table in 050P8

'24/09/2022
'multidim read/write check
uses console
indexbase 1
#minormajor 'default is majorminor
'dim int yx(4,5) 'static
int ym=4,xm=5
'redim int yx(ym,xm) 'dynamic
redim int yx[ym,xm] 'dynamic
dim int y,x,i
for y=1 to 4
  for x=1 to 5
    i++
    yx(y,x)=i
    print yx(y,x) tab
  next
  printl
next
printl
if #minormajor
  printl "column major order"
else
  printl "row major order"
endif
'test storage order for
'minrmajor and major minor
dim int nn at @yx
printl nn(1) tab nn(2) tab nn(3) tab nn[4]
wait
Title: Re: O2 Arrays / BASIC Standardization
Post by: Eduardo Jorge on October 01, 2022, 05:48:45 AM
good morning charles, i saw that o2 is already on 050P9
Has there been any significant changes or just bug fixes?
I'm having problems on the pc, so I won't be able to test
in the last example you posted the lines with "printl" alone, they gave an error.
  does it have something to do with my windows?, i still use win7 because of my pc that is a wagon, i was going to buy a 3rd generation xeon, but now the motherboard is giving a lot of critical error, now i'll have to wait having money to assemble a new pc because even if you buy used it is expensive since the Brazilian currency has devalued a lot, and I still suffer the risk of being taxed if I import the parts to get cheaper
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on October 01, 2022, 10:19:20 AM
Hi Eduardo,

I fixed a few problems with P9, including one affecting single dimensional redim. The printl problem is also resolved. Most of the bugs are from the library files, not core o2. I posted the last P9 about 5 housrs ago.

You may find the motherboard problems are most likely caused by dirty memory card / socket connections, especially if your climate is humid.

My apologies to anyone  emailing me. We have landline and slow internet problems making it impossible to access my bt mail.

This is a test for multidimensional objects. With the last P9, destructors are called in reverse order when the array is reduced in size.


uses console
printl "redimensioning objects"
printl
indexbase 1
int c
class obc
  int id
  method constructor()
    c++
    id=c
    printl "ob constructor " c
  end method
  method destructor
    printl "ob destructor "  id 
  end method
end class
'
printl "minimal array"
redim obc ob(1,1,1)
printl
printl "increase array"
redim obc ob(2,2,2)
printl
printl "reduce array"
c=0
redim obc ob(1,2,2)
wait


Github link to 050P9:
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P9.zip
Title: Re: O2 Arrays / BASIC Standardization
Post by: Nicola_Piano on October 23, 2022, 10:08:35 PM
Hi Charles.
I really like this implementation on multidimensional arrays.
Cheers

24-10-2022
I tried (with P12) your example and pleasantly noticed that UBOUND also works correctly for the size of the array.
Very good.

'24/09/2022
'multidim read/write check
uses console
indexbase 1
#minormajor 'default is majorminor
int ym=4,xm=5
redim int yx[ym,xm] 'dynamic
dim int y,x,i
for y=1 to 4
  for x=1 to 5
    i++
    yx(y,x)=i
    print yx(y,x) tab
  next
  printl
next
printl
if #minormajor
  printl "column major order"
else
  printl "row major order"
endif
'test storage order for
'minrmajor and major minor
dim int nn at @yx
printl ubound(yx,1)
printl ubound(yx,2)
printl nn(1) tab nn(2) tab nn(3) tab nn[4]
wait
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on October 25, 2022, 12:00:30 AM
I don't understand purpose of LBOUND and UBOUND for arrays
i found it in other dialects ..but why is there anyway ? ...never need to use it?
is that some kind of protections for array size ?
Title: Re: O2 Arrays / BASIC Standardization
Post by: Theo Gottwald on October 25, 2022, 11:38:28 AM
Assume that you get an ARRAY in a FUNCTION BYREF.
So how can you find out the dimensions of that ARRAY?
Yes, you can use L/UBOUND()

Example. Make a Function in PB that will REDIM an Array that is given as Parameter, conserving the Content.
You will only be able to make the function using LBOUND and UBOUND.
Title: Re: O2 Arrays / BASIC Standardization
Post by: Nicola_Piano on December 07, 2022, 05:46:43 PM
Well said Theo,
it's also useful when passing in an array the splitting of a string by a field separator character...
I have often used these commands.

I really appreciate what Charles is doing. :)
I'd like to have descriptions of the commands/functions he's implementing so I can put them in the help.

Cheers
Title: Re: O2 Arrays / BASIC Standardization
Post by: Zlatko Vid on December 07, 2022, 08:46:56 PM
QuoteI'd like to have descriptions of the commands/functions he's implementing so I can put them in the help

that would be nice Nicola...but require a lot of work ( i mean typing)
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on December 07, 2022, 09:39:49 PM
This is a reiteration from the bottom of page 4 of this topic. But strider is new.

The latest 050P14 implements:

indexbase  0 or 1 as previous
#majorminor  row-major order
#minormajor  column-major order
dims  number of dimensions
elements  total number of elements
lbound  base elements (currently the same as indexbase)
ubound  max element for each dimension (adjusted with indexbase)
scaler  the multiplier used on each dimension to calculate the element location
strider  the th scaler multiplied by the size of each element

UPDATE:
https://github.com/Charles-Pegge/OxygenBasic/blob/master/OxygenBasic050P14.zip

testlog:

MULTIDIMENSIONS

'17/09/2022
'multidim check
uses console
'#minormajor
'dim int d(1,2,3,4,5)
'redim int d(1,2,3,4,5)
redim int d(5,4,3,2,1)
redim int d(10,10,10,10,10)
d(1,2,1,4,5)=123
print d(1,2,1,4,5) cr
'redim int d(1,2,3,4,5)
'redim int d(60,2)
int i
for i=1 to dims(d)
  print ubound(d,i) tab scaler(d,i) cr
next
print cr

int *dd=@d
'for i=1 to ubound(d)
'print i tab dd(i) cr
'pos 80 == 0*120+1*60+0*20+3*5+1*4+indexbase
'next
wait

/*
'16/10/2022
'elements, dims
'ubound, lbound
'arwd
int cc,ee
'#show "t.txt"{
dim int d(1,2,3,4,5)
'cc=elements(d)
'ee= dims(d)
'void_ hah,hah
'indexbase 0
cc=lbound(d)
ee=ubound(d)
'}
'
'#recordof swap
'#recordof scaler
'print cc "   " ee
int i=1
'print dims(d)
'print elements(d)
'
for i=1 to dims(d)
  print " " scaler(d,i)
  'print " " lbound(d,i)
  'print " " ubound(d,i)
next
print ubound(d) " ok"
*/


DIMS, SCALER AND STRIDER

'11/10/2022
'array traversal
'test strider
uses console
redim int x(1,3,4)
x={1,2,3,4,5,6,7,8,9,10,11,12}
int i
int k
int*j
@j=@x 'element pointer j
for i=1 to dims(x)
  print "scaler and strider "+str(i)+tab+scaler(x,i)+tab+strider(x,i)+cr
next
printl
k=strider(x,2)
printl "test strider 2: " k
printl
for i=1 to ubound(x,2)
   print "val " i ":" tab j cr
   @j+=k 'stride
next
wait

Title: Re: O2 Arrays / BASIC Standardization
Post by: Nicola_Piano on December 08, 2022, 12:01:20 AM
Hi Charles.

Welcome P14.
O2 is growing!
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on December 09, 2022, 09:30:16 AM

I've also incorporated indexing into the core macros:

It is more useful to generate indexes than to sort the raw data directly.

reindex also supports filters.


'09/12/2022
'REINDEX TESTS
uses console
'indexbase 0
'int d={9,8,7,6,5,4,3,2,1,0}
'int d={8,9,6,7,4,5,2,3,0,1}
redim int d(100)
d={8,9,6,7,4,5,2,3,0,1}
redim int d(10)
int m=10
'
macro filter(r,i)
=================
if d[i]>=5
  r=1
endif
end macro
'
macro compare(r,i,j)
====================
'if d[i]>d[j] 'ascending
if d[i]<d[j] 'descending
  r=1
endif
end macro
'
reindex idx,m,n,filter,compare
'
'  idx     index to be created
'  m       count of data elements
'  n       count of resulting index
'  filter  filter macro
'  compare comparison macro
'
'PARTIAL USE OF REINDEX
'reindex idx,m,n,filter
'reindex idx,m,n,,compare
'reindex idx,m,n
'reindex idx,m : int n=m
'
'RESULTS
'=======
print "total " n cr cr
print "#"  tab "INDEX" tab "DATA" cr
int i,j
for i=indexbase to n+indexbase-1
  j=idx[i]
  print i tab j tab d[j] cr
next
print cr cr
del idx
wait
Title: Re: O2 Arrays / BASIC Standardization
Post by: Charles Pegge on December 09, 2022, 10:01:50 AM
Quote
Assume that you get an ARRAY in a FUNCTION BYREF.
So how can you find out the dimensions of that ARRAY?
Yes, you can use L/UBOUND()
Theo

Yes. As long as dynamic arrays are passed double-pointered:


'PASSING WHOLE REDIMMED ARRAYS
'
uses console
redim double a(5,10,20,4)
'
sub ff(double *d[])
===================
print "Test attributes of a passed dynamic array" cr cr
int i
print "dims: " tab dims(d) cr
print cr
print "n" tab "lbound" tab "ubound" tab "scaler" tab "strider" cr
for i=1 to dims(d)
  print i tab lbound(d,1) tab ubound(d,i) tab scaler(d,i) tab strider(d,i) cr
next
end sub
'
'TEST:
ff a
wait
del a