Problem with RESET? 
Author Message
 Problem with RESET?

In PB/CC 2.0 I have a TYPE and UNION defined similar to the following.  I
say similar since the actual TYPE is over 60 string fields and 5000 bytes --
too much to include here, I think ;-)

'==============================
TYPE ProfileType
     FirstName AS STRING * 15
     LastName AS STRING * 20
     HireDate AS STRING * 15
     Extension AS STRING * 5
     DirectLine AS STRING * 30
     Pager AS STRING * 30
     Email AS STRING * 60
     Epage AS STRING * 60
END TYPE

UNION ProfileUnion
     Rec AS STRING * 235
     Fld AS ProfileType
END UNION
'==============================
' elsewhere in the code...
LOCAL Emp AS ProfileUnion
'==============================
' and later, in several places...
RESET Emp
'==============================
' and ultimately this bit...
SEEK #nFile, nRec
PUT$ #nFile, Emp
'==============================

Here is the problem.  According to the docs, RESET should set all bytes in
the Emp variable to null -- ASCII 0.  Sometimes this works, which implies
that sometimes it doesn't.  Found this when the PUT$, even though Emp was
supposedly RESET, was writing the previous occupant of Emp to the file.
Confirmed in the de{*filter*} that sometimes Emp is set to null, and sometimes
not.  It is not random for the same instance (ie, if a particular RESET
works it seems to always work, and if it fails it seems to always fail.)  In
one case, there are two RESET commands in the same FUNCTION, just in
separate segments of a SELECT -- and one works, the other doesn't.

Simple to work around:  Emp.Rec = STRING$(SIZEOF(Emp), 0)

But, RESET is definitely not working as advertised all the time.  Until I
get resolution on what's happening I will just avoid RESET and use the work
around.

Is there a known problem with RESET?  Does it have an issue with UNIONs vs
TYPEs?  Would anyone like the actual code to test out?

Scott



Sat, 20 Apr 2002 03:00:00 GMT  
 Problem with RESET?
Scott, this is a known issue... at this time RESET works only with
arrays, not UDT's or scalar variables, contrary to the documentation..

Just FYI, UDT's and UNION's are limited to 16Kb in size.  You can of
course create arrays of UDT's and union's.

Quote:

>Here is the problem.  According to the docs, RESET should set all bytes in
>the Emp variable to null -- ASCII 0.  
>But, RESET is definitely not working as advertised all the time.  Until I
>get resolution on what's happening I will just avoid RESET and use the work
>around.
>Is there a known problem with RESET?  Does it have an issue with UNIONs vs
>TYPEs?  Would anyone like the actual code to test out?

Lance
powerbasic Support

-------------------------------------------------------------------------
PowerBASIC, Inc.      | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com



Sun, 21 Apr 2002 03:00:00 GMT  
 Problem with RESET?

Quote:

>Scott, this is a known issue... at this time RESET works only with
>arrays, not UDT's or scalar variables, contrary to the documentation..

As long as it works with arrays, just a thought for a workaround.....

DIM  MyUdt  AS MyUdtType
DIM MyByte(1:SIZEOF(MyUdt)) AS BYTE AT VARPTR (MyUDT)
RESET MyByte()

MCM



Sun, 21 Apr 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Problem with Reset Fields in ABC'Browse and MSSQL7

2. synchronous reset/set or asynchronous reset/set

3. Sync reset or async reset?

4. synchronous reset/set or asynchronous reset/set

5. The big problem: Do I reset all?

6. C5P-window reset problem

7. Problems with Position and Reset (C5EEB)

8. Problem using a Browse Box on a Pervasive.SQL table (RESET function)

9. Problem with JK-FF used as T-ff with sync.reset

10. $reset problems in 2.0.x

11. Reset problem

12. Resetting problem on Xilinx 4000 series

 

 
Powered by phpBB® Forum Software