Discussion:
[Gambas-user] Copying a folder and subfolders
neil lewis
2005-05-01 12:36:30 UTC
Permalink
Hi All,

I'm sure it's fairly trivial, but here goes.

I need to copy the contents of a folder which may include subfolders
(and maybe even sub-subfolders).
The notes for COPY say it can't be used recursively, so what's the best
way to do this?
I've checked the manual and the wiki and so far I can find no examples
or suggestions.

Neil Lewis
Tom
2005-05-01 12:49:39 UTC
Permalink
Post by neil lewis
Hi All,
I'm sure it's fairly trivial, but here goes.
I need to copy the contents of a folder which may include subfolders
(and maybe even sub-subfolders).
The notes for COPY say it can't be used recursively, so what's the best
way to do this?
I've checked the manual and the wiki and so far I can find no examples
or suggestions.
Neil Lewis
I had a similar problem with the MKDIR function that gambas has where I
couldnt create subdirectories recursively.
I solved this by just using the SHELL command though you could use EXEC as
well.

This way you can add your own options to the copy command.

Hope this helps,
-Tom
Fabien
2005-05-02 11:10:57 UTC
Permalink
Message du 01/05/05 14:39
Objet : [Gambas-user] Copying a folder and subfolders
Hi All,
I'm sure it's fairly trivial, but here goes.
I need to copy the contents of a folder which may include subfolders
(and maybe even sub-subfolders).
The notes for COPY say it can't be used recursively, so what's the best
way to do this?
I've checked the manual and the wiki and so far I can find no examples
or suggestions.
use this command :

sDest as STring
s
nando
2005-05-02 14:33:37 UTC
Permalink
Benoit,

Questions:
(1) Does the following...

PRIVATE my_array [4096, 16] as STRING

...occupy a static section of RAM or
is it dymanic depending on the size of string actually stored
in each element ?? (Remalloc'd every time there is an assignment?)

(2) Are byte,integer arrays MALLOC'd in a static section of RAM once??

Thanks
-Fernando
Benoit Minisini
2005-05-03 08:19:33 UTC
Permalink
Post by nando
Benoit,
(1) Does the following...
PRIVATE my_array [4096, 16] as STRING
...occupy a static section of RAM or
is it dymanic depending on the size of string actually stored
in each element ?? (Remalloc'd every time there is an assignment?)
The array itself is statically allocated in your class, but a string is just a
pointer to a malloc() allocation.

By doing this, an object of your class will take at least 4096 * 16 * 4 = 256
Kb !
Post by nando
(2) Are byte,integer arrays MALLOC'd in a static section of RAM once??
What do you mean by being "malloc'd" in a static section of ram once ???

There are two types of arrays in Gambas:

- "static arrays", declared with DIM array[x, y] AS Type
- "dynamic arrays", declared with DIM array AS NEW Type[x, y]

The dynamic arrays are true Gambas objects, like in Java, but not static ones.
Static arrays are allocated directly in the object they are declared (or in a
temporary allocation if you declared them as local variables in a method).
Post by nando
Thanks
-Fernando
Regardsn
--
Benoit Minisini
mailto:***@users.sourceforge.net
nando
2005-05-03 14:17:12 UTC
Permalink
Thank you.

About item (2) below - what I meant was:

would...
my_array [1234,12] = "HELLO"
my_array [1234,12] = "Good Bye"

perform a re-malloc to lengthen the string space requirements
because line 2 is longer than line 1 ?

-Fernando


---------- Original Message -----------
From: Benoit Minisini <***@users.sourceforge.net>
To: gambas-***@lists.sourceforge.net
Sent: Tue, 3 May 2005 10:19:33 +0200
Subject: [Gambas-user] About Gambas arrays
Post by Benoit Minisini
Post by nando
Benoit,
(1) Does the following...
PRIVATE my_array [4096, 16] as STRING
...occupy a static section of RAM or
is it dymanic depending on the size of string actually stored
in each element ?? (Remalloc'd every time there is an assignment?)
The array itself is statically allocated in your class, but a string
is just a pointer to a malloc() allocation.
By doing this, an object of your class will take at least 4096 * 16
* 4 = 256 Kb !
Post by nando
(2) Are byte,integer arrays MALLOC'd in a static section of RAM once??
What do you mean by being "malloc'd" in a static section of ram once ???
- "static arrays", declared with DIM array[x, y] AS Type
- "dynamic arrays", declared with DIM array AS NEW Type[x, y]
The dynamic arrays are true Gambas objects, like in Java, but not
static ones. Static arrays are allocated directly in the object they
are declared (or in a temporary allocation if you declared them as
local variables in a method).
Post by nando
Thanks
-Fernando
Regardsn
--
Benoit Minisini
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.
Get your fingers limbered up and give it your best shot. 4 great
events, 4 opportunities to win big! Highest score wins.NEC IT Guy
Games. Play to win an NEC 61 plasma display. Visit http://www.necitguy.com/?r=20
_______________________________________________
Gambas-user mailing list
https://lists.sourceforge.net/lists/listinfo/gambas-user
------- End of Original Message -------
Benoit Minisini
2005-05-03 14:28:27 UTC
Permalink
Post by nando
Thank you.
would...
my_array [1234,12] = "HELLO"
my_array [1234,12] = "Good Bye"
perform a re-malloc to lengthen the string space requirements
because line 2 is longer than line 1 ?
-Fernando
No. The string contents is allocated in its own place. The array contents are
just pointers to these strings.
--
Benoit Minisini
mailto:***@users.sourceforge.net
nando
2005-05-03 14:23:36 UTC
Permalink
Benoit,

My transition from VB to GAMBAS is progressing.
I want to use .ADD and .CLEAR for an array
but the syntax and usage eludes me.

If I do the following...

PRIVATE my_array [4096] as SHORT

I am having a difficulty using .CLEAR

my_array.clear reports it is not an object

I know I am missing something in my understanding here.
Can you aid in clearing my brain fog?


Thank you
-Fernando
Benoit Minisini
2005-05-03 14:29:25 UTC
Permalink
Post by nando
Benoit,
My transition from VB to GAMBAS is progressing.
I want to use .ADD and .CLEAR for an array
but the syntax and usage eludes me.
If I do the following...
PRIVATE my_array [4096] as SHORT
I am having a difficulty using .CLEAR
my_array.clear reports it is not an object
I know I am missing something in my understanding here.
Can you aid in clearing my brain fog?
Thank you
-Fernando
I can just repeat what I said in my previous mail:
- DIM array[xx] AS Type are static arrays, not objects.
- DIM array AS NEW Type[xx] are dynamic arrays, i.e. true Gambas objects.

Regards,
--
Benoit Minisini
mailto:***@users.sourceforge.net
nando
2005-05-03 15:25:38 UTC
Permalink
Note that

PRIVATE my_array AS NEW String[]

will not compile/run if a space exists
between String and the [
Benoit Minisini
2005-05-03 15:32:44 UTC
Permalink
Post by nando
Note that
PRIVATE my_array AS NEW String[]
will not compile/run if a space exists
between String and the [
Yes, this is a syntax error :-)
--
Benoit Minisini
mailto:***@users.sourceforge.net
Eilert
2005-05-04 07:50:05 UTC
Permalink
Bonjour Benoit,
Post by Benoit Minisini
Post by nando
Note that
PRIVATE my_array AS NEW String[]
will not compile/run if a space exists
between String and the [
Yes, this is a syntax error :-)
Is this wanted or just "something we cannot make better":

In practice, there are many cases where something counts from 0 but is
interpreted like 1, i. e. you will have to write a "- 1" here and there.

If you leave out the space, it is interpreted as a "-1" value, thus
leading to error messages.
Benoit Minisini
2005-05-04 09:53:03 UTC
Permalink
Post by Eilert
Bonjour Benoit,
Post by Benoit Minisini
Post by nando
Note that
PRIVATE my_array AS NEW String[]
will not compile/run if a space exists
between String and the [
Yes, this is a syntax error :-)
In practice, there are many cases where something counts from 0 but is
interpreted like 1, i. e. you will have to write a "- 1" here and there.
If you leave out the space, it is interpreted as a "-1" value, thus
leading to error messages.
Eilert
2005-05-04 10:57:07 UTC
Permalink
Post by Eilert
Bonjour Benoit,
Post by Benoit Minisini
Post by nando
Note that
PRIVATE my_array AS NEW String[]
will not compile/run if a space exists
between String and the [
Yes, this is a syntax error :-)
In practice, there are many cases where something counts from 0 but is
interpreted like 1, i. e. you will have to write a "- 1" here and there.
If you leave out the space, it is interpreted as a "-1" value, thus
leading to error messages.
nando
2005-05-04 15:13:56 UTC
Permalink
Example:

...
Timer1.Delay = 4000
Timer1.Enabled = True
....

Question:

During the 4 seconds that the Timer is ticking...
what is the appropriate way to reset the count to start over?

I know I could Disable then Enable, but that is 2 lines of code.
Would

Timer1.Delay = 4000

restart it while enabled?

-Fernando
Benoit Minisini
2005-05-04 15:20:48 UTC
Permalink
Post by nando
...
Timer1.Delay = 4000
Timer1.Enabled = True
....
During the 4 seconds that the Timer is ticking...
what is the appropriate way to reset the count to start over?
I know I could Disable then Enable, but that is 2 lines of code.
Would
Timer1.Delay = 4000
restart it while enabled?
Yes. At least the way I wrote the Timer class in Qt.
--
Benoit Minisini
mailto:***@users.sourceforge.net
Eilert
2005-05-04 07:38:09 UTC
Permalink
Hi Fernando,
Post by nando
Benoit,
My transition from VB to GAMBAS is progressing.
I want to use .ADD and .CLEAR for an array
but the syntax and usage eludes me.
neil lewis
2005-05-02 20:15:09 UTC
Permalink
Thanks, Fabien.

Neil Lewis
Post by Fabien
Message du 01/05/05 14:39
Objet : [Gambas-user] Copying a folder and subfolders
Hi All,
I'm sure it's fairly trivial, but here goes.
I need to copy the contents of a folder which may include subfolders
(and maybe even sub-subfolders).
The notes for COPY say it can't be used recursively, so what's the best
way to do this?
I've checked the manual and the wiki and so far I can find no examples
or suggestions.
sDest as STring
s
Loading...