Skip to content

Commit 2433000

Browse files
committed
FEAT: CHANGE: enable any value as a data type for WRITE action
1 parent d108457 commit 2433000

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/boot/actions.r

+1-1
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ read: action [
402402
write: action [
403403
{Writes to a file, URL, or port - auto-converts text strings.}
404404
destination [port! file! url! block!]
405-
data [binary! string! block!] {Data to write (non-binary converts to UTF-8)}
405+
data {Data to write (non-binary converts to UTF-8)}
406406
/part {Partial write a given number of units}
407407
length [number!]
408408
/seek {Write at a specific position}

src/core/p-file.c

+8
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,14 @@ REBINT Mode_Syms[] = {
447447
args = Find_Refines(ds, ALL_WRITE_REFS);
448448
spec = D_ARG(2); // data (binary, string, or block)
449449

450+
if (!(IS_BINARY(spec) || IS_STRING(spec) || IS_BLOCK(spec))) {
451+
//Trap1(RE_INVALID_ARG, spec);
452+
REB_MOLD mo = {0};
453+
Reset_Mold(&mo);
454+
Mold_Value(&mo, spec, 0);
455+
Set_String(spec, mo.series);
456+
}
457+
450458
// Handle the READ %file shortcut case:
451459
if (!IS_OPEN(file)) {
452460
REBCNT nargs = AM_OPEN_WRITE;

0 commit comments

Comments
 (0)