PSN-L Email List Message

Subject: RE: Basic Programming Help desired?
From: "Timothy Carpenter" geodynamics@.......
Date: Mon, 5 May 2008 10:40:15 -0400


Geoff,

My experience is with the various versions of MS Basic, not Powerbasic.
However, the following comments may help.

Check the effects of the various compiler directives on the speed of the
routine. In particular, check the effects of the various error handlers.
Turning them off may increase the speed.

I think your biggest hangup is creating a long string from your raw data --
that's a huge amount of unnecessary conversions. Instead, you should
consider creating a binary file () and then writing
(stream) the individual bytes to the file as soon as you receive them from
the AD card.

Here's a link to a routine that may give you some guidance:
http://www.vb-helper.com/howto_read_write_binary_file.html

Also, check the utilities and tools that may have accompanied your AD card.
Often the manufacturer will supply tools and/or examples that allow you to
stream data directly from the card to disk. Check their website too.

Some (most?) versions of Basic are intrinsically slow because they are not
truly compiled in the way FORTRAN would be. In your case it probably isn't
necessary, but if you really need the speed, then you should consider some
other language besides Basic -- e.g., C (C++), Fortran and ultimately,
Assembly.

Regards,
-Tim-


-----Original Message-----
From: psn-l-request@.............. [mailto:psn-l-request@............... On
Behalf Of Geoff
Sent: Monday, May 05, 2008 12:18 AM
To: PSN
Subject: Basic Programming Help desired?

Hello PSN Peoples;

I am trying to make a routine
that will save an array of single
bytes to a raw data file on the hard
drive and do this as quickly as possible.
Below you will see a routine that works
very well for me but its too darn slow.
When the program enters this routine
it will linger for many seconds
appearently converting the data array
into the strings before eventually
actually saving the data into the file.
I do not understand the terrible long
time this routine seems to take.

Can someone with more experience
please tell me what Im doing wrong
that takes so long ( literally several
seconds for only 32770 bytes total) to complete.
I would like a speed that rivals a BSAVE command.

This is how i save my seismic data
to a raw 8 bit file
after recording it to the array
in RAM.

Thanks for any help.
feel free ro email me direct.

Regards;
geoff

**********************************
POWERBASIC FOR DOS COMPILER SOURCE CODE

$LIB COM        ON
$LIB FULLFLOAT  ON
$LIB VGA        ON
$ERROR BOUNDS   ON
$ERROR NUMERIC  ON
$ERROR OVERFLOW ON
$ERROR STACK    ON
$CPU 80386
$COM    1024
$STRING 32
$STACK  2048
$SOUND  256
$DYNAMIC
$COMPILE EXE "TEST.EXE"
$FLOAT NPX
$OPTIMIZE SPEED
$EVENT
$OPTION CNTLBREAK ON

' CREATE AN ARRAY FOR RAW DATA
DIM VIRTUAL DATA_1?(0:32780)
' Fill the array with ascii text characters
' So resulting file can be easily examined
' with a hex editor normally this is the recording
FOR a = 0 to 32780 : DATA_1?(a) = ( 65 + a MOD 58 ) : NEXT a
' Form a file path and name
FILE1$ = "c:\data\test.dat"
' screen not necessary just habit
SCREEN 11
' below is the routine in question
tmpz1$ = ""
FOR ka = 0 to 32255
tmpz1$ = tmpz1$ + chr$(DATA_1?(ka))
NEXT ka
tmpz2$ = ""
FOR ka = 32256 to 32769
tmpz2$ = tmpz2$ + chr$(DATA_1?(ka))
NEXT ka
OPEN FILE1$ FOR BINARY AS #1
SEEK #1,0 : PUT$ #1,tmpz1$
SEEK #1,32256 : PUT$ #1,tmpz2$
CLOSE #1
tmpz1$ = "" : tmpz2$ = ""
' task completed return to system
SYSTEM


*****************************

__________________________________________________________

Public Seismic Network Mailing List (PSN-L)


__________________________________________________________

Public Seismic Network Mailing List (PSN-L)


[ Top ] [ Back ] [ Home Page ]