I have come across different explanations of how to write to a file
inside a starpack but still not everything is clear to me.
To start with: it does not work for me. Neither under linux nor WinXP
(which is my target).
It does not work in a sense that after I close the application and
start it again, the content of a file is not changed (or if I tried to
create a new file it does not exist). If I keep the app open, the data
seems to be modified without any problems.
The best explanation I found was that "most OS-es do not allow writing
to an opened binary file". OK, that fits but... Some people reported
that it actually works e.g.
http://groups.google.com/group/comp.lang.tcl/msg/9e01a5bec38338fe
So, I'd be really gratefull if somebody tells me how it can be done (if
at all).
Cheers,
Lukasz.
P.S. I've used the "-writable" flag it didn't help.
$ ./tclkit sdx unwrap writeTest.kit
5 updates applied
$ ./tclkit sdx wrap writeTest.exe -writable -runtime
tclkit-win32.8_4_9.exe
4 updates applied
- - - - - - - -- - - - - - - -
where tclkit is in fact:
tclkit-linux-x86-static.upx.bin
and where the code goes like this:
- - - - - - - -- - - - - - - -
set fileName test.txt
set directory $starkit::topdir
set theFile $directory/$fileName
if {![file exists $theFile]} {
log "dir before: [glob $directory/*]"
set handle [open $theFile w]
log "opened a new file"
puts $handle "writing..."
close $handle
log "dir after: [glob $directory/*]"
} else {
log "the file exists"
set handle [open $theFile r]
puts [set text [gets $handle]]
log "read $text"
close $handle
}
- - - - - - - -- - - - - - - -
plus some Tk code to show the log on the screen.
The first "glob" shows no "test.txt" file, the second shows it allrght:
- - - - - - - -- - - - - - - -
dir before: C:/Lukasz/testing/writeTest.exe/boot.tcl
C:/Lukasz/testing/writeTest.exe/config.tcl
C:/Lukasz/testing/writeTest.exe/lib
C:/Lukasz/testing/writeTest.exe/main.tcl
C:/Lukasz/testing/writeTest.exe/tclkit.ico
opened a new file
dir after: C:/Lukasz/testing/writeTest.exe/boot.tcl
C:/Lukasz/testing/writeTest.exe/config.tcl
C:/Lukasz/testing/writeTest.exe/lib
C:/Lukasz/testing/writeTest.exe/main.tcl
C:/Lukasz/testing/writeTest.exe/tclkit.ico
C:/Lukasz/testing/writeTest.exe/test.txt
- - - - - - - -- - - - - - - -
Now, if I close the app and start it over again it will look exactly
the same. If I don't close it, run the second instance it also shows
exactly the same.
Am I doing something wrong? Does anybody have it working on WinXP?
Lukasz.
Well, I had reported that I had it working on Win2K, but I was wrong.
This thread caused me to revisit my app with the intention of taking
some "See, it works for me!" screenshots, but I was in for a rude
awakening. The open and save dialog boxes were opening on another
location, outside the starpack, that just so happened to be the
corresponding directory in another copy of the unwrapped app (not the
same copy that I was wrapping). Because I saw all the right files, I
never noticed that they were in the wrong location.
The dialogs seem to remember somehow where they were last opened, and
open there the next time. Once I actually looked at the path in the
Win2K dialog, the error was obvious. I was unable to navigate to the
correct internal data directory, probably because the filesystem doesn't
see the VFS magic visible from inside the running starpack. Bummer.
> Well, I had reported that I had it working on Win2K, but I was wrong.
> [...]
> Bummer.
Bummer indeed. It would be so cool to be able to package the data and
the app inside one file. Easiest deployment ever :-)
Anyway, I just wanted to thank you guys for help. It's really great to
see a group on the net where people actually do help one another,
there's no spam, no flame wars etc :-) It should be listed as yet
another (and big) advantage of Tcl ;-)
With best regards,
Lukasz.
> Well, I can try, but I do not do anything special. Wrapping go as
> follows
[example snipped]
>
> Now, if I close the app and start it over again it will look exactly
> the same. If I don't close it, run the second instance it also shows
> exactly the same.
>
> Am I doing something wrong? Does anybody have it working on WinXP?
I tried this procedure as a starkit, and it wrapped and ran as it should on
Linux. The first time run, it created the file. Second and subsequent runs
reported the file contents.
When I tried to wrap it on WinXP, I had a whole different set of problems.
For some reason, the starkit was not appending the internal lib directory to
auto_path, so main.tcl was unable to load app-test. Very odd, and I don't
know what was wrong. I made sure that I had up-to-date tclkit 8.4.11. I
did notice that I had sdx.kit version 2005/03/01 17:05:05 39859-15319 and a
somewhat newer version 2005/03/15 11:52:42 26772-20616, neither of which
would create a satisfactory starkit, whether run on Linux or Windows, the
Windows version wouldn't work, but the Linux version would.
*sigh*
Bob
--
Bob Techentin techenti...@NOSPAMmayo.edu
Mayo Foundation (507) 538-5495
200 First St. SW FAX (507) 284-9171
Rochester MN, 55901 USA http://www.mayo.edu/sppdg/
Tk uses native file dialogs on Windows and Mac. Obviously
Tcl's internal VFS is not visible to the native OS.[*] If
you want to access the full FS+VFS then you need to resort
to the Tk file dialogs. I've posted before the 3 lines of
code that will get you there (they are always available in
Tk via their direct call).
[*] Actually it would be possible to expose the VFS to the OS
on Windows using a shell extension in process, but I have
never heard anyone attempt this. The same is likely possible
on OS X as well.
--
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos