gilbert189 @gilbert189

#iteration

printf This is number {a}.

if gt get a : echo 3 then printf {a} is greater than 3

if gt get a : echo 2 then printf {a} is greater than 2

if gt get a : echo 1 then printf {a} is greater than 1

@for a between 1 3 do exec iteration

(incomplete)

User	Dest.	Message

user	>>	POST ~
		#iteration...
user	<<	POST AA0E2C12C64E6C9B2097482F4F85B6BB
user	>>	POST ~
		@for a...
user	<<	POST CD9A0EFDF07F6648C1767B7C2268843E
for	<<	NOTIFY CALL CD9A0EFDF07F6648C1767B7C2268843E
for	>>	POST CD9A0EFDF07F6648C1767B7C2268843E
		@set a 1
for	<<	POST 31FA88F488821F1A7DE698A691830316
user	<<	NOTIFY POST 31FA88F488821F1A7DE698A691830316
set	<<	NOTIFY CALL 31FA88F488821F1A7DE698A691830316
set	>>	POST 31FA88F488821F1A7DE698A691830316
		ok
set	<<	POST 73778C119F392CB545825794A3B40F57
for	<<	NOTIFY POST 73778C119F392CB545825794A3B40F57
user	<<	NOTIFY POST 73778C119F392CB545825794A3B40F57
for	>>	POST CD9A0EFDF07F6648C1767B7C2268843E
		@exec iteration
for	<<	POST D640781713233FCD56F6D8E0FD7F40DD
user	<<	NOTIFY POST D640781713233FCD56F6D8E0FD7F40DD
exec	>>	SEARCH #iteration
exec	<<	LIST SEARCH #iteration
		AA0E2C12C64E6C9B2097482F4F85B6BB
exec	>>	POST AA0E2C12C64E6C9B2097482F4F85B6BB
		@printf This is number {a}.
exec	<<	POST CB2A3685926180D99391FC18D860F617
user	>>	NOTIFY POST CB2A3685926180D99391FC18D860F617
printf	<<	NOTIFY CALL CB2A3685926180D99391FC18D860F617
printf	>>	POST CB2A3685926180D99391FC18D860F617
		@get a
printf	<<	POST DA17B05BD4E9FB048227046102FD80DD
user	>>	NOTIFY POST DA17B05BD4E9FB048227046102FD80DD
get	<<	NOTIFY CALL DA17B05BD4E9FB048227046102FD80DD
get	>>	POST DA17B05BD4E9FB048227046102FD80DD
		1
get	<<	POST 62DA167D4CC1C08040C9B234BF9CDDA2
user	>>	NOTIFY POST 62DA167D4CC1C08040C9B234BF9CDDA2
printf	>>	NOTIFY POST 62DA167D4CC1C08040C9B234BF9CDDA2
printf	>>	POST AA0E2C12C64E6C9B2097482F4F85B6BB
		ok
printf	<<	POST 9B7B00195A133D9EE39BB4F67C4CE894
user	>>	NOTIFY POST 9B7B00195A133D9EE39BB4F67C4CE894
exec	>>	POST AA0E2C12C64E6C9B2097482F4F85B6BB
		@if gt get a : echo 3 then printf {a} is greater than 3
exec	<<	POST 75A5DB81995233375DE3B2E4A608CE8B
user	>>	NOTIFY POST 75A5DB81995233375DE3B2E4A608CE8B
if	<<	NOTIFY CALL 75A5DB81995233375DE3B2E4A608CE8B
if	>>	POST 75A5DB81995233375DE3B2E4A608CE8B
		@gt get a : echo 3
if	<<	POST F29BBE4DBD9117461A5B64D003C848C4
user	<<	NOTIFY POST F29BBE4DBD9117461A5B64D003C848C4
gt	<<	NOTIFY CALL F29BBE4DBD9117461A5B64D003C848C4
gt	>>	POST F29BBE4DBD9117461A5B64D003C848C4
		@get a
gt	<<	POST B3CB86D27F7DDEAC1750B611DAB8ABCF
user	<<	NOTIFY POST B3CB86D27F7DDEAC1750B611DAB8ABCF
if	<<	NOTIFY POST B3CB86D27F7DDEAC1750B611DAB8ABCF
get	<<	NOTIFY CALL B3CB86D27F7DDEAC1750B611DAB8ABCF
get	>>	POST B3CB86D27F7DDEAC1750B611DAB8ABCF
		1
get	<<	POST D794BFAD8AFE2E1949C546F1C5AE38DF
user	<<	NOTIFY POST D794BFAD8AFE2E1949C546F1C5AE38DF
	<<	NOTIFY POST D794BFAD8AFE2E1949C546F1C5AE38DF
Apr 23, 2023, 8:06 AM
8
View all

comments

Highlighted comment

First, user posts the a subroutine with the tag “#iteration”, then pings a for instruction. for is call-notified by this, and reposts user’s ping with a ping for a set instruction. set is call-notified and reposts with “ok”, post-notifying for to continue. for reposts its own post with an exec ping, call-notifying exec to search for “#iteration” and execute what’s inside. More pings and call-notifying and reposting and post-notifying and continuing (why doesn’t printf further ping echo?)

echo only re-posts the caller the content of the post, it’s used to return a value when post expects a sub-post

for example, on the post gt get a : echo 3, gt posts get a , wait until get re-posted, and then posts echo 3 and wait until echo re-posted. get re-posts whatever the variable a contains, while echo just re-posts 3 . In this case, gt will return true or false according to the re-posts. (a > 3)

(I might rename/merge gt with expr or something)

And I’m guessing for more complex expressions you’d set it to an intermediate variable first and then use get, because otherwise you’d have to differentiate between a calculation and result repost.