![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

What may be confusing is the early version of TRY returned an address on
the stack. The address is a *pointer* to a section of memory (buffer),
which, until TRY ended, contained the filename. When the object was
destroyed, the memory was released and probably reused. Sometimes this
can cause a Access Violation (GP) fault depending on how the memory area
was allocated. A technique useful in preventing this type of problem is
supplying TRY with the address of a memory buffer which you manage. TRY
should then store the filename in the buffer you passed it.
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com] On Behalf
Of Anil Rodrigues
Sent: Monday, June 13, 2005 1:46 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: FILENAME for open file
Mike, thanks, yes it helps.
I didn't realise the "temporariness" extended all the way=3D20 to the =
end
of "try", including stuff left on the stack.
Cheers! Anil
-----Original Message-----
From: Mike Ghan [mailto:MikeGhan_at_logix-controls.com]
Sent: Monday, June 13, 2005 4:37 PM
To: sftalk_at_forth.com
Subject: [sftalk] Re: FILENAME for open file
In TRY, the line=3D3D20
[OBJECTS MFDclass MAKES MFD OBJECTS] is creating a *temporary*
instance of the object MY-OFN-DIALOG which is valid only inside TRY.
The filename buffer is part of the object. You can either double buffer
it as with ZCOUNT PAD ZPLACE or change MFD to a static object:
MFDclass BUILDS MFD
: TRY ( -- zstr|0 )
MFD CHOOSE
IF MFD FILENAME ( zStr )
THEN 0 ( canceled ) ;
Or you could pass a buffer address to TRY.
Hope this helps,
Mike
-----Original Message-----
From: sftalk-bounce_at_forth.com [mailto:sftalk-bounce_at_forth.com] On Behalf
Of Anil Rodrigues
Sent: Monday, June 13, 2005 12:41 PM
To: sftalk_at_forth.com
Subject: [sftalk] FILENAME for open file
Can someone explain what I am missing as described below ? ( Mike ?)
Following is a stripped down section to get a filename for opening the
file. It works fine, using try pad zcount r/o open-file
However if I remove the "pad zcount zplace" from "try"
and let FILENAME leave the addr on the stack , it does not work.
Alternately; as is, " try pad zcount type " types the name correctly,
but with "pad...." removed, " try zcount type" prints junk.
The code follows:
Thanks, Anil
PACKAGE OFN-DIALOGS ( Re-open Package )
FILENAME-DIALOG SUBCLASS MY-OFN-DIALOG
: ACTION ( addr -- bool ) :: GetOpenFileName ;
END-CLASS
PUBLIC
MY-OFN-DIALOG SUBCLASS MFDclass
END-CLASS
END-PACKAGE
: TRY ( -- )
[OBJECTS MFDclass MAKES MFD OBJECTS]
MFD CHOOSE
IF MFD FILENAME ( zStr ) zcount pad zplace
\ ^ remove these words
THEN ;
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and
bug=3D20 reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Tue Jun 14 2005 - 08:43:11 PDT
This archive was generated by hypermail 2.2.0 : Thu Dec 04 2008 - 03:04:20 PST