I am using the view() function to open an ascii file from the shell, but it opens the file in the form/window in Virtuoso looking at the tail end of the file. EG if the ascii file is larger than the viewing window, the contents scroll down to the end of the file. Is there a way to use view() to open an ascii file but have the first view in the Virtuoso window remain at the head end of the file so the user can then scroll down instead of up?
Also, how can we create a path to write to a file location and pull from a specified path location by getting a path string from dbFullPath() and modifying it?
I am creating a new file using the cell name retrieved from geGetEditCellView()->cellName, but want to write to the same path location returned by dbFullPath() - with the exception of the last directory location.
For example, dbFullPath() returns ".../MyLibrary/MyLayout/layout/layout.cdb"
I create a file called "MyLayout_newfile" and want to write to ".../MyLibrary/MyLayout/MyLayout_newfile"
How do I truncate the end of the path returned by dbFullPath() - losing the "/layout/layout.cdb" portion?
What version are you using? The view() function doesn't do that for me - it shows the beginning of the file - the case it wouldn't by default is if you are passing t as the fourth argument to view(), and then updating the file after initially viewing it (the fourth argument is the auto-update flag, to "tail" the file live).
For your second question, I guess you're after geGetEditCellView()~>cell~>writePath
Given any path like /a/b/c/d/e, you can use the following:
path="/a/b/c/d/e"rindex(path "/") "/e"substring(path 1 strlen(path) - strlen(rindex(path "/"))) "/a/b/c/d"
My apologies and thanks again Andrew.
I am using v 5.1.41, and I think you are correct about the autoUpdate being responsible for this. When I use view(MyLayout_newfile), the form/window opens with the correct title, but is blank. So I was following the view() call with hiEnableUpdateWindowCB(), and this updated the window with the file contents, but scrolled to the tail (almost every time but for some reason not every time...and did not matter if the file already existed or not).
So this begs the question, how do I get my file contents to load in the window without forcing it with the hiEnableUpdateWindowCB() func?
And - geGetEditCellView()->cell->writePath is just what I wanted - thanks!
I don't really see why you should have to use hiEnableUpdateWindowCB(). Presumably you haven't finished writing to the file before you view it? Could you make sure the file is written, the output port closed, and then view it?
Otherwise there's also hiScrollWindowToIndex(hiGetCurrentWindow() 0) which could be used to scroll back to the top - but that sounds clunky...
Yes, it is possible the view() func is trying to load a file before it is written.
Here is more sample code:
ipcBeginProcess(strcat("shellscript" MyLayout_newfile)) ; creates output ascii file MyLayout_newfile_out in shell env
What code can I use to make sure the file is written, and the output port closed before viewing it?