Something is wrong

Started by Zlatko Vid, February 17, 2025, 08:59:27 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Zlatko Vid

Hi Charles
I compile this program in o2 SC604
and program not respond properly on goto statement.
How i know you may ask.
I compiled same code with old o2 A430
and program work properly
so i am asking ..is this SC604 version with bug?
here is code so you can test it :
'create stack using array by Aurel 17.2.2025 compiled with o2 SC604
#lookahead
string crlf = chr(13) + chr(10), stbuff
int stack[16] ,size = 10
int top ,exitp = 0

'push 10 values on the stack in reverse order
top = size
int v=1,x=10
while v <= 10
   push(x)
   x = x + 10
   v=v+1
wend

'test 1......
printStack()

goto exitProgram

sub push(int a)
    if top < 1
       print "Stack is underflow!" : goto exitProgram
    else
      stack[top] = a     ' enter value
      top = top - 1      ' decrement top
    end if
end sub

sub pop()
    if top > size
       print "Stack is Overflow!" : goto exitProgram
    else
      stack[top] = 0
      top = top + 1   ' increment stack index
    end if 
end sub 

sub printStack()
int i
    for i = 1 to size
        stbuff = stbuff + str(i) + " : " + str(stack[i]) + crlf
    next i
'show stack & exit
print stbuff
end sub

exitProgram:
exitp = exitp + 1
print "EXIT..." + str(exitp)

Charles Pegge

#1
Hi Aurel,

I cant remember SC604 but this works on the current version: (0.8.0)

Zlatko Vid

OK Charles
This is what should be and i am confused
because i compiled my interpreter micro(A)
and editor AurelEdit with this sc604 version and everything work properly
so i am surprised that goto is ignored in this case..strange.

just one thing
is this last version published on sourceForge?

Charles Pegge

I've just updated SourceForge :) Do I need to keep any of the old versions on there. Providing any support for them would be almost impossible.

Zlatko Vid

Thanks
Of course not ...but i keep some of them on my computers
and on some of my sites
I really don't get it what went wrong.
ok i will check again some of my other programs too.

Zlatko Vid

Ok
I download latest version from sForge
and i compile and try this simple program
again goto command is ignored

is it possible that this is somehow connected with gxo2 compiler
or with something else ?

32 bit ?

Zlatko Vid

I will tomorow compile all my programs
then i will see what to do.

Charles Pegge

#7
It's not the gxo2 compiler though I recommend using co2 since that is the one I maintain.

Are you still locking on to the older oxygen.dll ?

BTW You don't really need a goto in this instance because all the subs will be jumped over anyway. You can't accidently fall into a sub.

Zlatko Vid

Quote. You can't accidently fall into a sub.

yes but that is going to happen ..how i don't know?

In version sc604 i am using gxo2 as i always do
because i always think that co2 is for console apps only.

In latest gxo2 is under folder tools

Charles Pegge

gxo2 was compiled in FreeBasic whereas co2 is compiled in OxygenBasic and has more options. Both can be deployed from an IDE, or used in the command console.

Just one observation about your code example: you use push() and pop() subs. These names are assembler instructions, and you have overridden them, so you wont be able to use them in your program. However, If you are not using these assembler instructions in your program, it is not a problem.


Zlatko Vid

QuoteJust one observation about your code example: you use push() and pop() subs. These names are assembler instructions,

Oh man...how i know that ?
i don't have a clue about it
Ok if this names cause troubles it is easy to change . ;D
snap ...i forget that o2 is a assembler  :-[

about gxo2 and co2
I am able to use only gxo2 with my code editor
when i try to set compiler path to co2.exe nothing happened?
why is that ..i don't know .
thanks.

Zlatko Vid

Yes main problem is caused by push()
i will never figured that ..thanks  :)
'push 10 values on the stack in reverse order
top = size
int v,x=0

'while v < 11
for v = 1 to 10 
   ' push(x)
   x = x + 10
   print "V: " + str(v)
   'if v=10 :exit while : end if
   pushOnStack(x)
'end do
'wend
next v
print "V-after: "  + str(v)

'test 1......
printStack()



sub pushOnStack(int a)
    print "TOP: " + str(top)
    if top < 1
       print "Stack is underflow!" : goto exitProgram
    else
      stack[top] = a     ' enter value
      top = top - 1      ' decrement top
    end if
end sub



sub printStack()
int i
    for i = 1 to size
        stbuff = stbuff + str(i) + " : " + str(stack[i]) + crlf
    next i
'show stack & exit
print stbuff
end sub

exitProgram:
exitp = exitp + 1
print "EXIT..." + str(exitp)