PSN-L Email List Message

Subject: Re: Basic Programming Help desired?
From: "Geoff" gmvoeth@...........
Date: Mon, 5 May 2008 09:15:29 -0700


THANK you but this is not the problem I am addressing.
A/D is not the concern at this time.
ALL data is saved to an array that resides somewhere
in MSDOS EMS RAM. What I am trying to do is
save that array as fast as possible FROM RAM to a file
residing on hard disk. This lets me turn off the
disk while the recorder is running and turn on the drive
only for file operations ( permanent storage ).
I have always had troubles quickly dealing with
file formation and lots of bytes.
If you play with BSAVE command you will
find it is almost instant unlike my own programs.
If only I could make a program as fast as BSAVE
BASIC command then I could do anything I need to
in this regard very quickly and miss few samples
inbetween recordings.

Immediately below is the routine which does this
operation as fast as I have ever done it.
Comments are welcome.

Regards;
geoff

*************************
$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

DIM VIRTUAL DATA_1?(0:32780)

' Create a test set of data
FOR a = 0 to 32780 : DATA_1?(a) = ( 65 + a MOD 58 ) : NEXT a
' Create the path and filename
FILE1$ = "c:\data\test.dat"
' Write The Array in EMS RAM To The File on HARD Drive
CLS
PRINT "NOW SAVING DATA TO FILE c:\data\test.dat "
OPEN FILE1$ FOR BINARY AS #1
FOR ka = 0 to 7
  tmpz1$ = ""
  For kb = 0 to 4095
    kc = (( ka * 4096 ) + kb )
    tmpz1$ = tmpz1$ + chr$(DATA_1?(kc))
  NEXT kb
  kd = ( ka * 4096 )
  SEEK #1,kd : PUT$ #1,tmpz1$
NEXT ka
tmpz1$ = ""
FOR ka = 32256 to 32769
  tmpz1$ = tmpz1$ + chr$(DATA_1?(ka))
NEXT ka
SEEK #1,32256 : PUT$ #1,tmpz1$
CLOSE #1
tmpz1$ = ""
END
*********


----- Original Message ----- 
From: "Timothy Carpenter" 
To: 
Sent: Monday, May 05, 2008 7:40 AM
Subject: RE: Basic Programming Help desired?


> 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)
> 
> To leave this list email PSN-L-REQUEST@.............. with 
> the body of the message (first line only): unsubscribe
> See http://www.seismicnet.com/maillist.html for more information.
> 
> __________________________________________________________
> 
> Public Seismic Network Mailing List (PSN-L)
> 
> To leave this list email PSN-L-REQUEST@.............. with 
> the body of the message (first line only): unsubscribe
> See http://www.seismicnet.com/maillist.html for more information.
__________________________________________________________

Public Seismic Network Mailing List (PSN-L)


[ Top ] [ Back ] [ Home Page ]