Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Selectionbox, script which opens more than one file at once? Post 302215881 by tio86 on Thursday 17th of July 2008 11:19:56 AM
Old 07-17-2008
well this is what i have so far (see below)

i changed the function of the script a little but it works.
till now it opens the .doc files in the chosen folder (and then save it to mif).

but actually the script should open a template (N:Fame71\Templates) and import one file (the first) from the chosen folder, than save it and close it.
than the script should do it with all other files (second, third, ...) in the folder (open template, import .doc, save, close).

well i really have no idea how to write thes commands Smilie

maybe you can help me,
thx

Script:

Code:
   If fslVersionMajor < 3
      MsgBox 'FrameScript Version 3 oder hoeher wird benoetigt!';
      LeaveSub;
   EndIf



   DIALOGBOX Type(ChooseFile) Title('Verzeichnis der Doc-Dateien waehlen:')
             Mode(OpenDirectory) Button(btnvar) NewVar(gvFolder);
   IF btnvar = CANCELBUTTON
      LEAVESUB;
   ENDIF
   
   SET dirpath = gvFolder;
   
   SET totalFileCount = 0;
   SET MifFileCount = 0;
   SET WrdFileCount = 0;
   LOOP ForEach(File) In(dirpath) LoopVar(fname)
      SET totalFileCount = totalFileCount + 1;
      Find '.doc' InString(fname) NoCase Suffix  ReturnStatus(SuffixFound);
      IF SuffixFound   
         SET WrdFileCount = WrdFileCount + 1;
         RUN OpenImportAndSaveIt DocFileName(fname);
      ENDIF
   ENDLOOP
                  
   MsgBox 'Fertig  '+CHARLF+totalFileCount+' Dateien im Ordner '+
    CHARLF+WrdFileCount+' Doc-Dateien '+
      CHARLF+MifFileCount+' Mif-Dateien erzeugt';



SUB OpenImportAndSaveIt using DocFileName

   RUN isDocOpenAlready FileName(DocFileName) returns DocObj(docVar);
   IF docVar = 0
      SET AlreadyOpen = False;
      SET errorcode = 0;
      OPEN Document File(DocFileName) FileIsOldVersion FontNotFoundInDoc NewVar(docVar);
      IF ErrorCode not 0
         DISPLAY  'Error Opening Document-'+DocFileName+'  Msg-'+ErrorMsg;
      ENDIF
   ELSE
      SET AlreadyOpen = True;
   ENDIF

   IF docVar not = 0
      RUN GetNewFileSuffix InFileName(DocFileName) NewSuffix('mif') returns OutFileName(ofilename);
      SET errorcode = 0;
      SAVE Document DocObject (docVar) File(ofilename) FileType(SaveFmtInterchange);
      IF ErrorCode not = 0
         DISPLAY 'Save to MIF failed. Errorcode='+ErrorCode+'   Msg='+ErrorMsg;
      ELSE
         WRITE console 'Document ('+DocFileName+') saved as '+ofilename;
         SET MIFFileCount = MIFFileCount + 1;
      ENDIF;
    SAVE Document DocObject (docVar) FileType(SaveFmtInterchange);
    CLOSE Document DocObject(docVar) IGNOREMODS;
   ENDIF;

ENDSUB



SUB isDocOpenAlready using filename DocObj

   GET String FromString (filename) Uppercase NewVar(tfilename);
   SET DocObj = 0;
   LOOP foreach(Doc) In(Session) LoopVar(testdocobj)
      GET String FromString (testdocobj.Name) Uppercase NewVar(tname);
      IF tname = tfilename
         SET DocObj = testdocobj;
         LEAVELOOP;
      ENDIF
   ENDLOOP

ENDSUB



SUB GetNewFileSuffix using InFileName NewSuffix returns OutFileName
   
   SET SuffixDotPosition = -1;
   SET SuffixFound = 0;
   FIND '.' InString(InFileName) Back ReturnPos(SuffixDotPosition) ReturnStatus(SuffixFound);
   IF SuffixFound
      GET String FromString(InFileName) EndPos(SuffixDotPosition) NewVar(OutFileName)
      SET OutFileName = OutFileName + NewSuffix;
   ELSE
      SETOutFileName = OutFileName + '.' + NewSuffix;
   ENDIF

   Delete Var(dotpos);
   Delete Var(SuffixFound);
   
ENDSUB


 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

VI opens slow

when ever I try to vi a file that resides on another machines it takes forever for it to open. Does anyone have any ideas why it would be doing this? I have 7 unix machines and the only two that do this are both running tru64. (6 Replies)
Discussion started by: Moca4444
6 Replies

2. Linux

Port that a process opens up

Hi all, I have a process with PID as 12456. Could you please let me know how do i find out what is the port that process listens upon in Linux? Thanks in Advance, Pankajakshan (1 Reply)
Discussion started by: Pankajakshan
1 Replies

3. IP Networking

Port that a process opens up

Hi all, I have a process with PID as 12456. Could you please let me know how do i find out what is the port that process listens upon in Linux? Thanks in Advance, Pankajakshan (2 Replies)
Discussion started by: Pankajakshan
2 Replies

4. Shell Programming and Scripting

Position to last line when vi opens a file.

Any Idea without entering any keystroke I can go to end of line in vi when I opening the file. When I am opening Vi I want to goto last line. when I give vi + filename it does not work. Any clue why it does not work. Thanks. (3 Replies)
Discussion started by: ekb
3 Replies

5. OS X (Apple)

Programatically change which opens a file type

Hi there, If we have 2 apps on our customers machines that can both open files of a certain file extension, is there any way via shell commands to set which application should be the default? Essentially, I'm hoping to replicate Get Info > Open With > Change All, but using a script. Thanks... (0 Replies)
Discussion started by: davewg
0 Replies

6. Shell Programming and Scripting

include virtual perl-script - submit button opens a new page..

hello 2 all I can't understand how to insert a perl-script into .shml in a right way. <form> should be working but it's not doing that: <!--#include virtual="/cgi-bin/script.cgi?filename"--> filename is a name of the file which script is using the script is used for a score show (the number... (0 Replies)
Discussion started by: tip78
0 Replies

7. Web Development

include virtual perl-script - submit button opens a new page..

hello 2 all I can't understand how to insert a perl-script into .shml in a right way. <form> should be working but it's not doing that: <!--#include virtual="/cgi-bin/script.cgi?filename"--> filename is a name of the file which script is using the script is used for a score show (the number... (3 Replies)
Discussion started by: tip78
3 Replies

8. UNIX for Advanced & Expert Users

sendmails works, but opens 43 file handles per email -> problem

I'm using Sendmail 8.13.8 on a CentOS 5.5 vServer (Virtuozzo). I'm using a loop in PHP to send a lot of HTML-mails via sendmail. Each mail is a mail with individual statistics for our users, so its not mass mailing, bcc is not an option. It all works fine, but when I take a closer look there... (2 Replies)
Discussion started by: ZX81
2 Replies

9. Shell Programming and Scripting

[bash] Extra tab opens

Hello everyone, This code is working right using mate-terminal but with xfce4-terminal for some reason, it open up an extra tab... Could someone please help me out to understand why this is happening? #!/bin/bash cd "$(dirname "$0")"/files tab=" --tab" title=" --title" options=()... (2 Replies)
Discussion started by: soichiro
2 Replies
exit(1)                                                            User Commands                                                           exit(1)

NAME
exit, return, goto - shell built-in functions to enable the execution of the shell to advance beyond its sequence of steps SYNOPSIS
sh exit [n] return [n] csh exit [ ( expr )] goto label ksh *exit [n] *return [n] DESCRIPTION
sh exit will cause the calling shell or shell script to exit with the exit status specified by n. If n is omitted the exit status is that of the last command executed (an EOF will also cause the shell to exit.) return causes a function to exit with the return value specified by n. If n is omitted, the return status is that of the last command exe- cuted. csh exit will cause the calling shell or shell script to exit, either with the value of the status variable or with the value specified by the expression expr. The goto built-in uses a specified label as a search string amongst commands. The shell rewinds its input as much as possible and searches for a line of the form label: possibly preceded by space or tab characters. Execution continues after the indicated line. It is an error to jump to a label that occurs between a while or for built-in command and its corresponding end. ksh exit will cause the calling shell or shell script to exit with the exit status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the exit status is that of the last command executed. When exit occurs when executing a trap, the last command refers to the command that executed before the trap was invoked. An end-of-file will also cause the shell to exit except for a shell which has the ignoreeof option (See set below) turned on. return causes a shell function or '.' script to return to the invoking script with the return status specified by n. The value will be the least significant 8 bits of the specified status. If n is omitted then the return status is that of the last command executed. If return is invoked while not in a function or a '.' script, then it is the same as an exit. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words, following a command preceded by ** that are in the format of a variable assignment, are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign and word splitting and file name generation are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
break(1), csh(1), ksh(1), sh(1), attributes(5) SunOS 5.10 15 Apr 1994 exit(1)
All times are GMT -4. The time now is 01:01 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy