September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

@ -2,8 +2,9 @@
{{omit from|Déjà Vu}}
{{omit from|Gambas}}
{{omit from|GW-BASIC}}
{{omit from|Pascal}}
{{omit from|MATLAB|MATLAB has no multiline string literal functionality}}
{{omit from|VBA|VBA can't create a console application}}
A   ''here document''   (or "heredoc")   is a way of specifying a text block, preserving the line breaks, indentation and other whitespace within the text.
Depending on the language being used, a &nbsp; ''here document'' &nbsp; is constructed using a command followed by "<<" (or some other symbol) followed by a token string.

View file

@ -0,0 +1,56 @@
/* ARM assembly Raspberry PI */
/* program heredoc.s */
/* Constantes */
.equ STDOUT, 1 @ Linux output console
.equ EXIT, 1 @ Linux syscall
.equ WRITE, 4 @ Linux syscall
.equ BUFFERSIZE, 100
/* Initialized data */
.data
szMessString: .asciz "String :
ABCD
EFGH TAB \n"
szCarriageReturn: .asciz "\n"
/* UnInitialized data */
.bss
/* code section */
.text
.global main
main:
ldr r0,iAdrszMessString @ display message
bl affichageMess
100: @ standard end of the program
mov r0, #0 @ return code
mov r7, #EXIT @ request to exit program
svc 0 @ perform system call
iAdrszMessString: .int szMessString
iAdrszCarriageReturn: .int szCarriageReturn
/******************************************************************/
/* display text with size calculation */
/******************************************************************/
/* r0 contains the address of the message */
affichageMess:
push {r0,r1,r2,r7,lr} @ save registers
mov r2,#0 @ counter length */
1: @ loop length calculation
ldrb r1,[r0,r2] @ read octet start position + index
cmp r1,#0 @ if 0 its over
addne r2,r2,#1 @ else add 1 in the length
bne 1b @ and loop
@ so here r2 contains the length of the message
mov r1,r0 @ address message in r1
mov r0,#STDOUT @ code to write to the standard output Linux
mov r7, #WRITE @ code call system "write"
svc #0 @ call system
pop {r0,r1,r2,r7,lr} @ restaur registers
bx lr @ return

View file

@ -2,13 +2,13 @@
int main()
{
printf("\nThe Heredoc task was marked not implementable in C.\
\nFrankly the person who did so seems to have little idea of what C\
is capable of.\n\
After all, what would one call this multiline printf statement ?\
I may be old, but do not forget that it all started with me.\
\n\nEver enigmatic...\n\
C ");
return 0;
printf("\nThe Heredoc task was marked not implementable in C.\
\nFrankly the person who did so seems to have little idea of what C\
is capable of.\n\
After all, what would one call this multiline printf statement ?\
I may be old, but do not forget that it all started with me.\
\n\nEver enigmatic...\n\
C ");
return 0;
}

View file

@ -0,0 +1,10 @@
;; load cl-heredoc with QuickLisp
(ql:quickload 'cl-heredoc)
;; use #>xxx>yyyyyyyy!xxx as read-macro for heredoc
(set-dispatch-macro-character #\# #\> #'cl-heredoc:read-heredoc)
;; example:
(format t "~A~%" #>eof1>Write whatever (you) "want",
no matter how many lines or what characters until
the magic end sequence has been reached!eof1)

View file

@ -26,7 +26,7 @@
here dup >R
BEGIN refill >R
get_line 2dup EOD compare
R> AND \ notEOD && input-stream ->
R> AND \ notEOD && input-stream ->
WHILE rot $!+ EOL!+
REPEAT 2drop
R> tuck - dup allot

View file

@ -0,0 +1,28 @@
get-current get-order wordlist swap 1+ set-order definitions
: place over >r rot over cell+ r> move ! ;
: +place 2dup >r >r dup @ cell+ + swap move r> r> dup @ rot + swap ! ;
: count dup cell+ swap @ ;
set-current
CREATE eol 10 C, DOES> 1 ;
CREATE eod 128 ALLOT DOES> count ;
: seteod 0 parse ['] eod >body place ;
: start 0 0 here place ;
: read refill 0= IF abort" Unterminated here document" THEN ;
: ~end source eod compare ;
: store source here +place eol here +place ;
: slurp BEGIN read ~end WHILE store REPEAT refill drop ;
: totalsize here count + here - ;
: finish totalsize ALLOT align ;
: << seteod start slurp finish DOES> count ;
previous
( Test )
CREATE Alice << ~~ end ~~
They got a building down New York City, its called Whitehall Street,
Where you walk in, you get injected, inspected, detected, infected,
Neglected and selected.
~~ end ~~
Alice type bye

View file

@ -1,5 +1,5 @@
INTEGER I !A stepper.
CHARACTER*666 I AM !Sufficient space.
INTEGER I !A stepper.
CHARACTER*666 I AM !Sufficient space.
I AM = "<col72
C 111111111122222222223333333333444444444455555555556666666666
C 123456789012345678901234567890123456789012345678901234567890123456789
@ -10,8 +10,8 @@ C 123456789012345678901234567890123456789012345678901234567890123456789
5"
Chug through the text blob.
DO I = 0,600,66 !Known length.
WRITE (6,1) I AM(I + 1:I + 66) !Reveal one line.
1 FORMAT (A66) !No control characters are expected.
END DO !On to the next line.
DO I = 0,600,66 !Known length.
WRITE (6,1) I AM(I + 1:I + 66) !Reveal one line.
1 FORMAT (A66) !No control characters are expected.
END DO !On to the next line.
END

View file

@ -0,0 +1,8 @@
print_string {whatever|
'hahah', `this`
<is>
\a\
"Heredoc" ${example}
in OCaml
|whatever}
;;

View file

@ -1,5 +1,7 @@
print(<<EOF
Mary had
a little
EOF
. "lamb\n");
sub flibbertigibbet {
print <<~END;
Mary had
a little
lamb
END
}

View file

@ -1,5 +1,5 @@
if true; then
cat <<- EOF
The <<- variant deletes any tabs from start of each line.
EOF
cat <<- EOF
The <<- variant deletes any tabs from start of each line.
EOF
fi

View file

@ -1,8 +1,8 @@
'Purpose: Converts TXT files into VBS code with a function that returns a text string with the contents of the TXT file
' The TXT file can even be another VBS file.
' The TXT file can even be another VBS file.
'History:
' 1.0 8may2009 Initial release
' 1.0 8may2009 Initial release
'
'
Const ForReading = 1
@ -19,7 +19,7 @@ objDialog.InitialDir = WshShell.CurrentDirectory
intResult = objDialog.ShowOpen
If intResult = 0 Then
WshShell.Popup "No file selected.", 2, " ", 64
WshShell.Popup "No file selected.", 2, " ", 64
Wscript.Quit
Else
strFileNameIN = objDialog.FileName
@ -30,18 +30,18 @@ strFileNameOUT= strFileNameIN & "_CONVERTED.Vbs"
'Check if strFileNameOUT exists already
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileNameOUT) then 'does the file EXIST?
' WScript.Echo "found"
OVRWT=MSGBOX(strFileNameOUT & " exists already"&vbCRLF&"Overwrite?",vbYesNoCancel,"Overwrite?")
if OVRWT = 6 then
'proceed
objFSO.DeleteFile(strFileNameOUT)
else
WshShell.Popup "Exiting as requested.", 1, " ", 64
Wscript.Quit
End If
' WScript.Echo "found"
OVRWT=MSGBOX(strFileNameOUT & " exists already"&vbCRLF&"Overwrite?",vbYesNoCancel,"Overwrite?")
if OVRWT = 6 then
'proceed
objFSO.DeleteFile(strFileNameOUT)
else
WshShell.Popup "Exiting as requested.", 1, " ", 64
Wscript.Quit
End If
Else
' WScript.Echo "not found" 'strFileNameOUT does NOT exists already
' WScript.Echo "not found" 'strFileNameOUT does NOT exists already
END if
strBaseName=objFSO.GetBaseName(strFileNameIN)
@ -61,7 +61,7 @@ strText = Replace(strText, strOldText, strNewText)
'Add objTXTFile.writeline ("
strOldText = VBCRLF
strNewText = """) &vbCrLf"&VBCRLF&" strText=strText& ("""
strNewText = """) &vbCrLf"&VBCRLF&" strText=strText& ("""
strText = Replace(strText, strOldText, strNewText)
'Converting done
@ -73,10 +73,10 @@ objFile.WriteLine "'this Function will return a string containing the contents o
objFile.WriteLine "msgbox "&strBaseName &"()"
objFile.WriteLine vbCrLf
objFile.WriteLine "Function "&strBaseName&"()"
objFile.WriteLine " 'returns a string containing the contents of the file called "&strFileName
objFile.WriteLine " Dim strText"
objFile.WriteLine " strText= ("""&strText&""") &vbCrLf"
objFile.WriteLine " "&strBaseName&"=strText"
objFile.WriteLine " 'returns a string containing the contents of the file called "&strFileName
objFile.WriteLine " Dim strText"
objFile.WriteLine " strText= ("""&strText&""") &vbCrLf"
objFile.WriteLine " "&strBaseName&"=strText"
objFile.WriteLine "End Function"
objFile.Close

View file

@ -14,7 +14,7 @@ your text, a workaround is to drop out of the CDATA section, output part of the
terminator, then start a new CDATA section and output the rest. Let's do this
now:
]]>]]<![CDATA[>
]]>]]<![CDATA[>
Newlines and spacing are retained as well, as long as they're evaluated in a
context that bothers preserving them. Whether or not the spaces before and after