Are there any tricks that can speed up or sidestep use of the text import wizard when I have 8-10 identically formatted text files to import? Each one is an order, so they have to be done one at a time. I tried recording an import which yields this, for example:
I’ve saved the template already, but in my imagination I’d only have to drag in the text file and the remaining steps would happen without any clicking. As it is now, I still have to tell the import to replace the existing data. And I get an error message if I leave the import wizard window open while doing other stuff. If I close it, then I have to reselect the template each time.
And the procedure only contains the path to the file I used when recording. That needs to change for each new import.
This is all niggling stuff, I know, but I feel like if I just knew more, I could code this so it would be truly a drag and drop and everything would be done without extra clicks or random error messages.
Re: [Panorama Discussion Forum] [Panorama X] Repeated text file imports
The text file being imported in your procedure is the one you chose when recording the procedure. You would likely want to replace the “/Users/bkahn/Downloads/BF#5614 794174” with a variable and fill that variable with the desired file name prior to running the importtext function.
I tried that too. (Maybe at age 70 I am striving for a new level of laziness?) And it works, but copying and pasting the new file name–sitting in the downloads folder-- so that the variable can do it’s thing is also not very elegant.
Is there a way to do this with the drag receiver object in a form? I didn’t see any examples of how to use it in the tutorial but if I could drag each text file into there and have the rest happen ‘automatically’ that seems like a slick solution.
I have done something like this with drag receiver. Here are the bare bones of a procedure:
/*This procedure will use a drag receiver to build an array of file path names,
with a cr() separator, for files dropped on the drag receiver.
Then you can use loop array to process those files. */
fileglobal lvtext,lvnewfile,lvcounter,lvtextfiles
lvtextfiles=info("dropfiles")
lvnewfile=""
looparray lvtextfiles, cr(), lvtext, lvcounter
/* The first time through the loop, the procedure will use the first file name,
load that file into a variable. Then you can use an import procedure to
process that variable. Then it will move to the next file, and so on, to
the end of the list of files dropped.*/
lvnewfile=fileload(lvtext)
//[Your procedure for importing one file]
endloop
I am not sure if you would have to do something different for a binary file, but it looks like this structure would still work.
Rather than having to create a drag receiver you can simply use a gettext to drag the file to from the Finder. The only gotcha is that you first have to click into the gettext edit box to make it active before you do the drag.
local theFilePath
gettext "Drag filke from Finder…", theFilePath
This puts the file path into the variable theFilePath ready to use in your import procedure.
Too bad the normal Text Editing Object does not also support this drag receiver characteristic. I have to assume it is a different animal than the text input box used with gettext and the choosefiledialog.
If the Text Editing object is already active (flashing insertion point) then you can drag text or files into it. But if it is not active yet, it doesn’t work (I agree that could be nice, and it would also be nice if Image Display objects could be used as drag receivers).
Not in my experimenting. With the TEO active (the focus ring highlighted and insert cursor flashing), draged text or a file does not get entered when dragged into the object.
I can’t explain your results – I did the same experiment before I posted and it worked. Ok, I tried it again, it still works, here is a movie.
In any case, this is not Panorama code doing this, but standard macOS behavior. So maybe you are on a different version of macOS and it is somehow working differently.
In my case the Text Editor object was linked to a database field – what was yours linked to?
Ok, I just found the problem. I was simply dragging the text into the middle of the TEO instead of into the line that had the blinking cursor. Once I saw my error I noticed that the dragged text would show a + cursor when I was over the line in the TEO with the blinking cursor.
By the way, in addition to dragging files into Text Editor objects, you can also drag a file into procedure code and the path will be copied into the code. I’m sure some of you already know this, but perhaps this will be a helpful tip for some. I just thought of this because I was doing some programming and needed the path of a file – so I just dragged it into the code from the Finder!
I have jumped through the new hoops and mostly get things done in PanX now, almost as quickly as in the old 6 days. However, there is a bug(?) in the template saving routine. It will not accurately save a template that does not import the first field. Every field is shifted over to the left. After some hours of thrashing, I kludged by using the little formula box at lower right of the window to add a blank line (return) at the beginning, which shifts everything over one field to the right, and it now works. Shouldn’t have to do it this way, and if there is a “right” way to do it, I’d like to know.