Entry
sub2: Using version 2.0 of TSE, is there a way to copy and paste to Windows applications?
Nov 8th, 2001 16:03
Knud van Eeden,
[Internet: see:
http://www.faqts.com/knowledge_base/view.phtml/aid/12621/fid/900]
ad 2. the 'copy to Windows clipboard' macro for the external program
(here TSE v3.0 for Windows):
(save this in the macro directory of TSE v3.0, and compile this
macro as 'cliptwtd.s')
---
FORWARD PROC Main()
FORWARD PROC PROCClipboardWPasteTseWindowsTseDos()
FORWARD STRING PROC FNFilenameTemporaryClipboardWindowsS()
FORWARD PROC PROCClipboardWPasteBlockToFileContentClear( STRING s1 )
FORWARD PROC PROCFileSaveOverwrite( STRING s1 )
FORWARD PROC PROCFileAbandon( STRING s1 )
FORWARD PROC PROCFileContentClearNoReturn( STRING s1 )
FORWARD PROC PROCClipboardWPaste()
FORWARD PROC PROCFileEdit( STRING s1 )
FORWARD PROC PROCFileSaveOverwriteCurrent()
FORWARD PROC PROCFileAbandonCurrent()
FORWARD INTEGER PROC FNGetBufferIdI()
FORWARD PROC PROCBufferGoto( INTEGER i1 )
FORWARD PROC PROCBufferEmptyCurrent( INTEGER i1 )
FORWARD PROC PROCFileSaveAsOverwritePromptNo( STRING s1 )
FORWARD INTEGER PROC FNFileEditB( STRING s1 )
FORWARD PROC PROCErrorFileNotFound( STRING s1 )
FORWARD PROC PROCFileSaveAsOverwrite( STRING s1 )
FORWARD STRING PROC FNFileNameCurrentS()
FORWARD INTEGER PROC FNFileAbandonB()
FORWARD PROC PROCWarn( STRING s1 )
FORWARD INTEGER PROC FNGetBufferCentralIdI( STRING s1 )
FORWARD INTEGER PROC FNBufferGotoB( INTEGER i1 )
FORWARD PROC PROCFileSaveAsOption( STRING s1, INTEGER i1 )
FORWARD PROC PROCError( STRING s1 )
FORWARD STRING PROC FNCons3S( STRING s1, STRING s2, STRING s3 )
FORWARD PROC PROCMessageCons( STRING s1, STRING s2 )
FORWARD INTEGER PROC FNFileSaveAsOptionB( STRING s1, INTEGER i1 )
FORWARD PROC PROCPositionPush()
FORWARD INTEGER PROC FNLineNumberCurrentT()
FORWARD PROC PROCPositionPop()
FORWARD STRING PROC FNConsS( STRING s1, STRING s2 )
FORWARD PROC PROCMessage( STRING s1 )
FORWARD STRING PROC FNStringConcatSeparatorS( STRING s1, STRING s2,
STRING s3 )
FORWARD INTEGER PROC FNStringEmptyB( STRING s1 )
FORWARD INTEGER PROC FNStringEqualB( STRING s1, STRING s2 )
// --- MAIN --- //
PROC Main()
PROCClipboardWPasteTseWindowsTseDos()
END
<F12> Main()
// --- LIBRARY --- //
// library: clipboard: copy clipboard via TSE v3.0 for windows to TSE
v2.5 for DOS (filenamemacro=cliptwtd.s) [kn, ri, su, 26-08-2001
06:34:28]
PROC PROCClipboardWPasteTseWindowsTseDos()
// e.g. PROC Main()
// e.g. PROCClipboardWPasteTseWindowsTseDos()
// e.g. END
// e.g.
// e.g. <F12> Main()
STRING filenametemporaryS[255] = FNFilenameTemporaryClipboardWindowsS()
PROCClipboardWPasteBlockToFileContentClear( filenametemporaryS )
PROCFileSaveOverwrite( filenametemporaryS )
PROCFileAbandon( filenametemporaryS )
AbandonEditor() // go back to DOS() after running
END
// library: clipboard: copy clipboard via TSE v3.0 for windows to TSE
v2.5 for DOS: temporary filename [kn, ri, su, 26-08-2001 06:36:08]
STRING PROC FNFilenameTemporaryClipboardWindowsS()
RETURN( "c:\dddxxx.xzy" )
END
// library: cut/copy/paste: block: clipboard: paste: paste block to
file [kn, ri, su, 26-08-2001 06:42:17]
PROC PROCClipboardWPasteBlockToFileContentClear( STRING filenameS )
PROCFileContentClearNoReturn( filenameS )
PROCClipboardWPaste()
END
// library: file: save: overwrite: given filename [kn, ri, su, 26-08-
2001 07:00:12]
PROC PROCFileSaveOverwrite( STRING filenameS )
PROCFileEdit( filenameS )
PROCFileSaveOverwriteCurrent()
END
// library: file: abandon: via editing this file, then abandon [kn, ri,
tu, 21-08-2001 22:57:34]
PROC PROCFileAbandon( STRING filenameS )
PROCFileEdit( filenameS )
PROCFileAbandonCurrent()
END
// library: file: delete: clear the contents of the file [kn, zoe, we,
15-11-2000 11:19:37]
PROC PROCFileContentClearNoReturn( STRING filenameS )
// e.g. <F12> PROCFileContentClear( "myfile" )
INTEGER fileP
PROCFileEdit( filenameS )
fileP = FNGetBufferIdI() // get current bufferid
PROCBufferGoto( fileP ) // goto this buffer
PROCBufferEmptyCurrent( fileP )
PROCFileSaveAsOverwritePromptNo( filenameS )
END
// library: cut/copy/paste: clipboard: paste: paste from clipboard [kn,
ni, ma, 03-08-98 13:06:10]
PROC PROCClipboardWPaste()
// e.g. <F12> PROCClipboardWPaste()
PasteFromWinClip()
END
// library: file: edit: edit a file, with test of problems [kn, ri, za,
02-01-1999 19:28:37]
PROC PROCFileEdit( STRING filenameS )
// e.g. <F12> PROCFileEdit( "myfile" )
// variation: IF NOT FNFileEditB( "" ) // opens a prompt box for a
filename
// variation: IF NOT FNFileEditB( "*.*" ) // opens a prompt box with
filename to choose from
// variation: IF NOT FNFileEditB( filenameS, _DONT_PROMPT_ ) // does
not display any warnings
// variation: IF NOT FNFileEditB( filenameS, _DONT_LOAD_ )
IF NOT FNFileEditB( filenameS )
PROCErrorFileNotFound( filenameS )
ENDIF
END
// library: file: save: overwrite: current filename [kn, ri, su, 26-08-
2001 07:00:12]
PROC PROCFileSaveOverwriteCurrent()
PROCFileSaveAsOverwrite( FNFilenameCurrentS() )
END
// library: file: quit: abandon: (Exit File--No Save. Removes the
current or specified buffer from the editor, without any prompt,
discarding all unsaved changes). Syntax: AbandonFile( [ INTEGER
buffer_id ] ). See also: FileChanged(), QuitFile(), SaveAndQuitFile(),
EmptyBuffer() [kn, zoe, wo, 16-06-1999 01:06:25]
PROC PROCFileAbandonCurrent()
IF NOT FNFileAbandonB()
PROCWarn( "file could not be abandoned" )
ENDIF
END
// library: (Returns the Unique Id of Requested or Current Buffer) O
GetBufferId([STRING name])* [kn, zoe, th, 25-01-2001 11:12:56]
INTEGER PROC FNGetBufferIdI()
RETURN( FNGetBufferCentralIdI( FNFilenameCurrentS() ) )
END
// library: buffer: goto: goto the numbered buffer [kn, zoe, di, 03-10-
2000 18:56:20]
PROC PROCBufferGoto( INTEGER fileP )
// e.g. <F12> PROCBufferGoto( FNBufferCreateTemporaryI() )
IF NOT FNBufferGotoB( fileP )
PROCWarn( "Buffer: Goto: : Not succesful" )
ENDIF
END
// library: delete: text: buffer: delete: all: deletes all the text in
the current buffer [kn, ni, ma, 02-08-1999 04:47:49]
PROC PROCBufferEmptyCurrent( INTEGER fileP )
// e.g. <F12> PROCBufferEmptyCurrent( FNBufferCreateTemporaryI() )
EmptyBuffer( fileP )
END
// library: file: save: save as: overwrite and no prompt [kn, ri, su,
26-08-2001 07:48:19]
PROC PROCFileSaveAsOverwritePromptNo( STRING filenameS )
PROCFileSaveAsOption( filenameS, _OVERWRITE_ | _DONT_PROMPT_ )
END
// library: file: edit: edit a file, with test of problems [kn, ni, ma,
03-08-98 13:08:39]
INTEGER PROC FNFileEditB( STRING filenameS )
// e.g. <F12> PROCMessage( FNFileEditB( "myfile" ) ) // gives TRUE
IF NOT EditFile( filenameS )
PROCErrorFileNotFound( filenameS )
RETURN( FALSE )
ENDIF
RETURN( TRUE )
END
// library: error: file: not: found [kn, ri, we, 28-02-2001 23:02:12]
PROC PROCErrorFileNotFound( STRING filenameS )
PROCError( FNCons3S( "file: ", filenameS, " not found / path does not
exist" ) )
END
// library: file: save: save as: overwrite [kn, zoe, tu, 10-10-2000
19:29:50]
PROC PROCFileSaveAsOverwrite( STRING filenameS )
// e.g. <F12> PROCFileSaveAsOverwrite( "myfilename" )
PROCFileSaveAsOption( filenameS, _OVERWRITE_ )
END
// library: file: filename: get: current: return current filename (as a
string containing the complete path) (Get Full Name of Current Buffer)
[kn, ni, za, 08-08-1998 00:02:37] [FNfilenamecurrent]
STRING PROC FNFileNameCurrentS()
// e.g. <F12> PROCMessage( "Current filename = ",
FNFilenameCurrentS ) // gives e.g. c:\temp\ddd.dok
RETURN( CurrFilename() )
END
// library: file: quit: abandon: (Exit File--No Save. Removes the
current or specified buffer from the editor, without any prompt,
discarding all unsaved changes). Syntax: AbandonFile( [ INTEGER
buffer_id ] ). See also: FileChanged(), QuitFile(), SaveAndQuitFile(),
EmptyBuffer() [kn, zoe, wo, 16-06-1999 01:06:25]
INTEGER PROC FNFileAbandonB()
// e.g. <F12> PROCMessage( FNFileAbandonB() ) // gives non zero number
if successful, zero (FALSE) on failure
RETURN( AbandonFile() )
END
// library: error: warning: give a warning message [kn, zoe, wo, 09-06-
1999 22:11:07]
PROC PROCWarn( STRING s )
// e.g. <F12> PROCWarn( "you have forgotten to input a value" )
Warn( s )
END
// library: (Returns the Unique Id of Requested or Current Buffer) O
GetBufferId([STRING name])* [kn, zoe, th, 25-01-2001 11:12:23]
INTEGER PROC FNGetBufferCentralIdI( STRING filenameS )
RETURN( GetBufferId( filenameS ) )
END
// library: buffer: goto: goto the numbered buffer [kn, zoe, di, 03-10-
2000 18:56:20]
INTEGER PROC FNBufferGotoB( INTEGER fileP )
// e.g. <F12> PROCMessage( FNBufferGotoB( FNBufferCreateTemporaryI
() ) ) // gives ...
RETURN( GotoBufferId( fileP ) <> 0 )
END
// library: file: save: save as (Saves Current Buffer on Disk Under
Specified Name) O SaveAs([STRING filename [, INTEGER option]])* [kn,
ri, zo, 28-03-1999 04:52:46]
PROC PROCFileSaveAsOption( STRING filenameS, INTEGER optionI )
// e.g. <F12> PROCFileSaveAsOption( "myfilename", _DEFAULT_ )
// e.g. <F12> PROCFileSaveAsOption( "myfilename", _APPEND_ )
// e.g. <F12> PROCFileSaveAsOption( "myfilename", _OVERWRITE_ )
// e.g. <F12> PROCFileSaveAsOption( "myfilename", _DONT_PROMPT_ )
PROCMessageCons( "saving file (save as):", filenameS )
IF NOT FNFileSaveAsOptionB( filenameS, optionI )
PROCerror( "file: " + filenameS + ": could not be 'saved as'" )
ENDIF
END
// library: error: central routine [kn, ni, ma, 03-08-98 13:08:12]
// INTEGER ErrorGB = FALSE
PROC PROCError( STRING s )
// e.g. <F12> PROCError( "this is an error" )
PROCPositionPush()
// Alarm()
// PROCWarn( s )
// Message( s )
// PROCWarn( "Linenr ", FNLineNumberCurrentT(), ": ", s )
Message( "Linenr ", FNLineNumberCurrentT(), ": ", s )
// only when seriously: PROCFileTextInsertEnd( "line " + STR(
FNLineNumberCurrentT() ) + ": " + s, filenameerrorGS, TRUE )
// errorGB = TRUE
PROCPositionPop()
END
// library: string: concatenation: 3 strings [kn, zoe, fr, 17-11-2000
13:52:07]
STRING PROC FNCons3S( STRING s1, STRING s2, STRING s3 )
RETURN( FNConsS( FNConsS( s1, s2 ), s3 ) )
END
// library: message: via 2 strings [kn, ri, su, 29-07-2001 18:24:52]
PROC PROCMessageCons( STRING s1, STRING s2 )
PROCMessage( FNConsS( s1, s2 ) )
END
// library: file: save: save as [kn, ri, zo, 28-03-1999 04:52:46]
INTEGER PROC FNFileSaveAsOptionB( STRING filenameS, INTEGER optionI )
// e.g. <F12> PROCMessage( FNFileSaveAsOptionB( "filename",
_APPEND_ ) )
INTEGER saveasokB = TRUE
PROCMessageCons( "saving file (save as):", filenameS )
IF NOT SaveAs( filenameS, optionI )
PROCerror( "file: " + filenameS + ": could not be 'saved as'" )
saveasokB = FALSE
ELSE
saveasokB = TRUE
ENDIF
RETURN( saveasokB )
END
// library: push/pop: position: store: push [kn, zoe, vr, 04-06-1999
23:01:00]
PROC PROCPositionPush()
// e.g. <F12> PROCPositionPush()
PushPosition()
// pushpopGT = pushpopGT + 1 // for checking purposes on the end of
your routines. This must give 0 (as there as as many +1 as -1 in the OK
case)
END
// library: line: position: linenumber: return the current linenumber
(Get the Number of Current Line) [kn, ni, ma, 02-08-1999 00:46:42]
INTEGER PROC FNLineNumberCurrentT()
RETURN( CurrLine() )
END
// library: push/pop: position: restore: pop [kn, zoe, vr, 04-06-1999
23:01:00]
PROC PROCPositionPop()
// e.g. <F12> PROCPositionPop()
PopPosition()
// pushpopGT = pushpopGT - 1 // for checking purposes on the end of
your routines. This must give 0 (as there as as many +1 as -1 in the OK
case)
END
// library: string: concatenation: concatenation 2 words tot 1 word
(separated by a comma) [kn, ri, wo, 25-11-1998 20:15:03]
STRING PROC FNConsS( STRING s1, STRING s2 ) // version with test if
string empty
// e.g. <F12> PROCMessage( FNConsS( "knud", "van" ) )
RETURN( FNStringConcatSeparatorS( s1, s2, " " ) )
END
// library: (Write Specified Expression(s) on Editor Status Line) R
Message(expr [, expr2]...)* [kn, zoe, wo, 16-06-1999 01:07:07]
PROC PROCMessage( STRING s )
Message( s )
END
// library: string: concatenation: concatenate 2 words to 1 word,
separated by separator S [kn, zoe, do, 01-07-1999 01:33:18]
STRING PROC FNStringConcatSeparatorS( STRING s1, STRING s2, STRING
separatorS )
IF FNStringEmptyB( s1 ) RETURN( s2 ) ENDIF
IF FNStringEmptyB( s2 ) RETURN( s1 ) ENDIF
RETURN( s1 + separatorS + s2 )
END
// library: string: empty: is given string empty? [kn, ri, za, 20-05-
2000 20:11:08]
INTEGER PROC FNStringEmptyB( STRING s )
RETURN( FNStringEqualB( s, "" ) )
END
// library: string: equal: Are two given strings equal? [kn, zoe, wo,
04-10-2000 18:23:27]
INTEGER PROC FNStringEqualB( STRING s1, STRING s2 )
// e.g. <F12> PROCMessage( FNStringEqualB( "knud", "knud" ) ) // gives
TRUE
// e.g. <F12> PROCMessage( FNStringEqualB( "knud", "van" ) ) // gives
FALSE
RETURN( s1 == s2 )
END
---