my best effort

General discussion for topics related to the FreeBASIC project or its community.
Post Reply
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: my best effort

Post by owen »

The fbcadcam Philippines project is about freeBASIC but also much more.
We are fortunate indeed that Sir Emerson (an engineer who works in a pudding factory) is part of this project.

https://www.fbcadcam.net/forum/viewtopi ... p=531#p527
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: my best effort

Post by owen »

Although Sir Emerson is unfamiliar with freeBASIC (for the moment), he is a good candidate for understanding freeBASIC. However he works a full time job and his contribution to the project may better serve as a math teacher and other things for example, he will soon be helping them build the frame to hold the maslow cnc router. His attitude, willingness to help reminds me of counting_pine:
viewtopic.php?f=8&t=7441&start=60

counting_pine was reluctant to do the math for me yet because he was willing to share (teach me / "help out") i was able to move on an continue the work for the fbcad project...

I was just reviewing the posts in the fbcad project to try and best select a fb forum moderator and still undecided. Who ever is selected to mod the forum I will say in advance to that mod, thanks. And ps I know I have overstepped the forum rules as of recent in many ways and I thank you all for the leniency.
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: my best effort

Post by owen »

I head to the PI tomorrow.
At the moment I am home doing some last minute things like take the Christmas lights off the roof (maybe). Actually i'm constepating about that idea rather i thought i would try to figure out how to use CURL and hopefully share it with the kids in the pi but im genius cuz i cant get it to work. this stuff about missing this or that dll file has me stumped. if'n anyone would like to help me know how to get curl to working give me a shout.

anyhow... wife and i are quite excited to see the kids and i hope to share vast amounts of FB know how with them during my 2 week stay.
ps you (the fb community) are welcome to skype (live) with me if'n u b so inclined.

cheers, owen
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: my best effort

Post by owen »

congrats to the Imortis wish you well for such a task. and congrats to the FB community... let's move forward.
and to dodicat, wow, 40 years in service on the big blue u got my respect for that in itself. im ex squid 6 yrs submarine service (85 - 91).
once 7.5 months under with only snorkeling for a breath of fresh air a few days somewhere in between.
at least that how i remember it. ps i looked into that bit of detail about a year ago only to find out my sea story was a bit embellished as records show we came up for a breath of fresh air a couple times and for perhaps a couple weeks but no matter i like my memory (version) better.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

"fbcadcam.net/forum/" is it down (I get no page or a blank page depending on broswer)?
owen
Posts: 555
Joined: Apr 19, 2006 10:55
Location: Kissimmee, FL
Contact:

Re: my best effort

Post by owen »

Sorry for not posting first what was going on.

In upgrading from shared hosting to vps so I can do some stuff.
jmgbsas
Posts: 35
Joined: Dec 26, 2020 16:03

Re: my best effort

Post by jmgbsas »

paul doe wrote:
owen wrote:OK I admit it: I am new to oop. In prep for Paul's contribution I am trying to explain some stuff and ran into a question about passing UDT's through subs and functions.
Ironic, since I'm actually coding the little game I mentioned using purely procedural programming. There's no OOP in sight, so don't worry too much about it for now =D
owen wrote:Why does draw_ball_2(ByRef b) not work?
You don't need to specify the 'byref' clause when you pass the parameter, only on the function prototype:

Code: Select all

ScreenRes 600,400
Window(0,0)-(600,400)

Type ball
   x As Integer
   y As Integer
   r As Integer
   c As Integer
End Type

Declare Sub draw_ball_1(ByVal aball As ball)
Declare Sub draw_ball_2(ByRef aball As ball)
Declare Sub draw_ball_3(aball As ball)

Dim b As ball
b.x=300
b.y=200
b.r=100
b.c=14

Circle(b.x,b.y),b.r,b.c
Print "press any key"
Sleep
Cls
b.c=13
draw_ball_1(b)
Circle(b.x,b.y),b.r,b.c
Print "press any key"

Sleep
draw_ball_2(b)
Circle(b.x,b.y),b.r,b.c
Print "press any key"

Sleep
draw_ball_3(b)
Circle(b.x,b.y),b.r,b.c
Print "press any key"

Sleep


Sub draw_ball_1(ByVal aball As ball)
   Circle(aball.x,aball.y),aball.r,aball.c
   aball.r=50
End Sub

Sub draw_ball_2(ByRef aball As ball)
   Circle(aball.x,aball.y),aball.r,aball.c
   aball.r=200
End Sub

Sub draw_ball_3(aball As ball)
   Circle(aball.x,aball.y),aball.r,aball.c
   aball.r=300
End Sub
See? Your code works flawlessly without them =D
------------
Hi,
How Do yo pass UDT Arrays?
I can not do it, only shared array, I do a trick for do REDIM in sub and funciton is running but only with shared array for example
In main module I have

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type
' ---------------------
Dim Shared As inst Roll
......
ReDim (Roll.trk ) (NB To NA, 1 To CantTicks)

' The array run ok in shared mode and I can do a redim inside a funtion or sub !!
But I can not to pass it as parameter for example in this cases, if I use as parameter
sub ( Roll as inst) or
sub (Roll() as inst) or
sub (Roll() as dat)

sub (Roll.trk() as inst
all give me error when I compile
Default types or suffixes are only valid in -lang deprecated or fblite or qb, found '.' in 'Declare Sub creaPenta (c AS cairo_t Ptr, Roll.trk() As inst )'
The '.' is part of the definition of the array and the compiler confuse the situation,,,
.--- it is imposible to do it ?
I tested with
ReDim (Roll.trk ) (NB To NA, 1 To CantTicks) ' dynamic array
and with
Dim (Roll.trk ) (NB To NA, 1 To CantTicks) ' no dynamic
The only thing that can do is to obtain a dynamic array redim in any sub or funciton but frebasic say that
can not do it, but I can do it,,,,
But pass as parameter the array I can not do it yet the compiler stop,,,, I keep trying,,¿?,

Thanks
Lost Zergling
Posts: 534
Joined: Dec 02, 2011 22:51
Location: France

Re: my best effort

Post by Lost Zergling »

Roll.trk is dat, not inst. Added : Maybe you could have a look here viewtopic.php?f=8&t=27695
about issues related to passing arrays (lzae exotic, bit complex and incomplete)
Last edited by Lost Zergling on Jul 15, 2021 18:27, edited 1 time in total.
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

Examples:

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type
' ---------------------
Dim As inst Roll


' ------------- examples
Sub si(i as inst)
    redim i.trk(2, 3)
End Sub
' ---- or
Sub sd(d() As dat)
    redim d(2, 3)
End Sub
' ---------------------
si(Roll)
' ---- or
sd(Roll.trk())
jmgbsas
Posts: 35
Joined: Dec 26, 2020 16:03

Re: my best effort

Post by jmgbsas »

fxm wrote:Examples:

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type
' ---------------------
Dim As inst Roll


' ------------- examples
Sub si(i as inst)
    redim i.trk(2, 3)
End Sub
' ---- or
Sub sd(d() As dat)
    redim d(2, 3)
End Sub
' ---------------------
si(Roll)
' ---- or
sd(Roll.trk())
ok Thanks but I need to share or to pass the data inside the array to follow processing in another sub
you have
Sub si(i as inst)
redim i.trk(2, 3)
End Sub

then i need to pass a parameter that new array

Sub si(i as inst)
redim i.trk(2, 3)
process i.trk() <---- another call to sub process, and there, I have error the compiler do not like '.' i.trk is not ' accepted as name
End Sub

==> "i.trk" is not valid name for an array that is the problem
Thanks
José
dodicat
Posts: 7976
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: my best effort

Post by dodicat »

Passing an array of udt is always byref
Passing udt is default byref, but you can choose byval.

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type

sub R1( Roll as inst)
      print "R1"
      print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

sub R2(Roll() as inst)
      print "R2"
      print lbound(Roll);" to ";ubound(Roll);" Main array"
      for n as long=lbound(Roll) to ubound(Roll)
            print lbound(roll(n).trk,1);" to ";ubound(roll(n).trk,1);" , "; lbound(roll(n).trk,2);" to ";ubound(roll(n).trk,2)
            next n
      end sub
      
sub R3( Roll() as dat)
     print "R3"
     print lbound(roll);" to ";ubound(roll)
      end sub

sub R4(byval roll as inst)
      redim roll.trk(4,4)
      print "Inside R4"
       print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

var nb=1,na=4,cantTicks=3
Dim  As inst Roll
ReDim (Roll.trk ) (NB To NA, 1 To CantTicks)
R1(Roll)
print
dim as inst a(1 to 5)
for n as long =1 to 5
 ReDim (a(n).trk ) (NB To NA+n, 1 To CantTicks+n) 
 next
R2(a())
print
dim as dat d(2)
R3(d())
print
dim as inst k
R4(k)
print
print "Outside"
print lbound(k.trk,1);" to ";ubound(k.trk,1);" , "; lbound(k.trk,2);" to ";ubound(k.trk,2)
sleep

  
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: my best effort

Post by fxm »

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type
' ---------------------
Dim As inst Roll



Sub process(d() as dat)
    d(1, 2).vol = 1
end sub
' ---------------------
Sub si(i as inst)
    redim i.trk(2, 3)
    process i.trk()
End Sub
' ---------------------
si(Roll)
jmgbsas
Posts: 35
Joined: Dec 26, 2020 16:03

Re: my best effort

Post by jmgbsas »

Lost Zergling wrote:Roll.trk is dat, not inst. Added : Maybe you could have a look here viewtopic.php?f=8&t=27695
about issues related to passing arrays (lzae exotic, bit complex and incomplete)
Thanks I will see the topic.....I am new beginners is a a big topic ...
jmgbsas
Posts: 35
Joined: Dec 26, 2020 16:03

Re: my best effort

Post by jmgbsas »

dodicat wrote:Passing an array of udt is always byref
Passing udt is default byref, but you can choose byval.

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type

sub R1( Roll as inst)
      print "R1"
      print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

sub R2(Roll() as inst)
      print "R2"
      print lbound(Roll);" to ";ubound(Roll);" Main array"
      for n as long=lbound(Roll) to ubound(Roll)
            print lbound(roll(n).trk,1);" to ";ubound(roll(n).trk,1);" , "; lbound(roll(n).trk,2);" to ";ubound(roll(n).trk,2)
            next n
      end sub
      
sub R3( Roll() as dat)
     print "R3"
     print lbound(roll);" to ";ubound(roll)
      end sub

sub R4(byval roll as inst)
      redim roll.trk(4,4)
      print "Inside R4"
       print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

var nb=1,na=4,cantTicks=3
Dim  As inst Roll
ReDim (Roll.trk ) (NB To NA, 1 To CantTicks)
R1(Roll)
print
dim as inst a(1 to 5)
for n as long =1 to 5
 ReDim (a(n).trk ) (NB To NA+n, 1 To CantTicks+n) 
 next
R2(a())
print
dim as dat d(2)
R3(d())
print
dim as inst k
R4(k)
print
print "Outside"
print lbound(k.trk,1);" to ";ubound(k.trk,1);" , "; lbound(k.trk,2);" to ";ubound(k.trk,2)
sleep

  
Ok Thanks so much I will try it
jmgbsas
Posts: 35
Joined: Dec 26, 2020 16:03

Re: my best effort

Post by jmgbsas »

jmgbsas wrote:
dodicat wrote:Passing an array of udt is always byref
Passing udt is default byref, but you can choose byval.

Code: Select all

Type dat Field=1
nota As UByte
dur As UByte
vol As UByte
pan As UByte
pb As UByte
inst As UByte
End Type
' --------------- and then
Type inst
As dat trk(Any, Any)
End Type

sub R1( Roll as inst)
      print "R1"
      print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

sub R2(Roll() as inst)
      print "R2"
      print lbound(Roll);" to ";ubound(Roll);" Main array"
      for n as long=lbound(Roll) to ubound(Roll)
            print lbound(roll(n).trk,1);" to ";ubound(roll(n).trk,1);" , "; lbound(roll(n).trk,2);" to ";ubound(roll(n).trk,2)
            next n
      end sub
      
sub R3( Roll() as dat)
     print "R3"
     print lbound(roll);" to ";ubound(roll)
      end sub

sub R4(byval roll as inst)
      redim roll.trk(4,4)
      print "Inside R4"
       print lbound(roll.trk,1);" to ";ubound(roll.trk,1);" , "; lbound(roll.trk,2);" to ";ubound(roll.trk,2)
end sub

var nb=1,na=4,cantTicks=3
Dim  As inst Roll
ReDim (Roll.trk ) (NB To NA, 1 To CantTicks)
R1(Roll)
print
dim as inst a(1 to 5)
for n as long =1 to 5
 ReDim (a(n).trk ) (NB To NA+n, 1 To CantTicks+n) 
 next
R2(a())
print
dim as dat d(2)
R3(d())
print
dim as inst k
R4(k)
print
print "Outside"
print lbound(k.trk,1);" to ";ubound(k.trk,1);" , "; lbound(k.trk,2);" to ";ubound(k.trk,2)
sleep

  
Ok Thanks so much I will try it
Result:
My problem was the use of Declare <--
Declare Sub creaPenta (c AS cairo_t Ptr, Roll As inst )

if I delete the Declare the error dissapear but I need to move de Definition of Sub before the main code all run ok
... the compiler do not work good with Declare , I used Declare to haqve a clean module main
and all Sub code in another place or module but is something dirty
I will use a #Include to avoid to see the sub code before main code,,
Thanks, in that way run, I will never use 'Declare ' any more for now,,,
Post Reply