Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Oct 20 22:59
    @dockimbel banned @SmackMacDougal
  • Dec 03 2017 05:53
    @PeterWAWood banned @matrixbot
  • Sep 28 2016 12:19
    @PeterWAWood banned @TimeSeriesLord
  • Aug 13 2016 03:23
    @PeterWAWood banned @Vexercizer
Boleslav Březovský
@rebolek
What do you mean by regular semicolon?
laturk
@laturk
I want it to print.
Boleslav Březovský
@rebolek
print ";"
laturk
@laturk
OK. Thanks.
Sunnypt
@Sunnypt
Hello, I was looking at the Red parse, back in early 2018 - 'A DSL compiler' by Nenad - on the Red home page
  • it worked fine Apr 6th 2018 and older, but newer and newest builds do not work - I just cant see why - looks like a 'parse' change. - Please help.
    thank you Sunny.
hiiamboris
@hiiamboris
what compiler? you have a link?
You need to scroll down a way to find it.
hiiamboris
@hiiamboris
ah, basic... let me see..
Sunnypt
@Sunnypt
yes, it worked fine early 2018 - but now it fails - I just do'nt know enough to work out why - I am guessing it's a 'parse' thing, but not sure.
hiiamboris
@hiiamboris

it looks like a bug to me:

>> parse [LET] ['let]
== false

introduced between April 6 and April 12

I see that @9214 already reported a regression https://github.com/red/red/issues/3029#issuecomment-436438710
Sunnypt
@Sunnypt
if it is, please let them know - i dont know how to. thanks
ah, ok thank you
hiiamboris
@hiiamboris
@greggirwin you might wanna reopen that ticket
@Sunnypt you can workaround it for now by uppercasing every keyword of the parse rule I believe
@Sunnypt thanks for getting our attention to it
Sunnypt
@Sunnypt
thanks The workaround does not work
Vladimir Vasilyev
@9214
@Sunnypt try the other way around - use lowercase keywords.
do-basic [
    10 let A = "hi!"
    20 let N = 3
    30 print A
    40 let N = N - 1
    50 if N > 0 then goto 30
]
Gregg Irwin
@greggirwin
Thanks All. @PeterWAWood beat me to reopening the ticket.
burque505
@burque505
Might I ask where would be a good place to post a fix for a script at Short Red Code Examples? The "Coin Flip" example does not work for me with v0.64 (64-bit). I have a modified version that does. Thanks!
Vladimir Vasilyev
@9214
@burque505 site's maintainer hasn't been active in a long while, so your fix is unlikely to be incorporated.
burque505
@burque505
@9214, thanks. Is there a good site for users to post working scripts?
Vladimir Vasilyev
@9214
burque505
@burque505
Thanks!
burque505
@burque505

Hello, I have the following code using Red/System that appears to property #import Autohotkey.dll. In using this DLL (whether from Autohotkey or not) it's frequently imperative to insert a delay after the code runs, or the command won't be executed. The simple script in AHK to run Notepad may illustrate this.<br> AhkCom := ComObjCreate("AutoHotkey.Script") AhkCom.ahktextdll("Run notepad.exe") While AhkCom.ahkReady() Sleep, 100 <br>The red-lang code I have so far is this: ```Red/System []

import

[
    "AutoHotkey.dll" cdecl 
    [
        Exec: "ahktextdll" [pointer! [integer!]]
    ]
]

Exec ["Run notepad.exe"]``` <br>No delay is inserted, because I can't find any documentation on how to insert a delay in Red/System. the Red 'wait' command does not work. All help appreciated. Also greatly appreciated would be any examples of using #import for any non-Windows-OS DLLS, and any real-world examples of using the Visual Basic API as described here at Visual Basic API. Thanks in advance.

hiiamboris
@hiiamboris
burque505
@burque505

@hiiamboris, thanks. Sorry about that code above. This formatting is still alien to me. I ran out of edits. I'll try again:

Red/System []

#import 
    [
        "AutoHotkey.dll" cdecl 
        [
            Exec: "ahktextdll" [pointer! [integer!]]
        ]
    ]

Exec ["Run notepad.exe"]

sleep (1000)

'sleep' threw an error.

GiuseppeChillemi
@GiuseppeChillemi
Could a function know if it has been called recursively without passing any arguments or setting any refinement regarding this ?
hiiamboris
@hiiamboris
@GiuseppeChillemi you can use a static counter inside your function
GiuseppeChillemi
@GiuseppeChillemi
@hiiamboris avoiding reinitializing it if the counter is higher than zero.
Yes, it is a solution.
Thanks
hiiamboris
@hiiamboris
☻ like this: f: context [d: 0 return func [n] [d: d + 1 if 1 < n [f n - 1] probe pick ["recursive" "flat"] d > 1 d: d - 1]]
>> f 3
"recursive"
"recursive"
"flat"
== 0
or other way around, f: context [d: 0 return func [n] [d: also d do [d: d + 1 if 1 < n [f n - 1] probe pick ["recursive" "flat"] d > 1]]]
GiuseppeChillemi
@GiuseppeChillemi
I have another question:
I wish to navigate in a foreach/forall loop blocks like in: 'a-block: [a b c [e d f] g] printing all letters, so reaching the [e d f] block it should go inside, print everithing and then go back to the upper level and continue.
I see no simple solution to this, expecially a recursive one.
hiiamboris
@hiiamboris
use parse's builtin recursion
GiuseppeChillemi
@GiuseppeChillemi
Still don't know how to enter inside a block. Could you please make a simple example or point me to documentation ?
hiiamboris
@hiiamboris
sure, on it... sec
foreach-deep: function ['w b c] [parse b rule: [any [ahead block! into rule | b: skip (set w :b/1 do c)]]]
>> foreach-deep x [a b c [e d f] g] [probe x]
a
b
c
e
d
f
g
== true
hiiamboris
@hiiamboris
@burque505 c'mon man, can't you copy/paste these lines into your code or what:
#import ["kernel32.dll" stdcall [
    Sleep: "Sleep" [
                dwMilliseconds    [integer!]
    ]
]]
GiuseppeChillemi
@GiuseppeChillemi

@hiiamboris your first example is complex for me:

f: context [
    d: 0 
    return func [n] 
    [d: d + 1 
        if 1 < n [f n - 1] 
        probe pick ["recursive" "flat"] d > 1 d: d - 1
    ]
]

So, lets go.

f: context [
    d: 0

Here you create a context and you initialize it.

return func [n]

I don't understand what you are doing here.
It seems you return a function but I to me RETURN is an istruction which get executed at object creation and I do not know who is RETURN returning the value too !
Also, func [n] to me need to be assigned to a word...

probe pick ["recursive" "flat"] d > 1 d: d - 1

I have already encountered this kind of expression, but I don't rememeber how it works.

Maybe I should read it this way:
probe pick ["recursive" "flat"] d > 1 
d: d - 1
burque505
@burque505

Thanks, that fixed the "sleep" part of my code ... now for the dll call, which apparently did NOT work. @hiiamboris, you know red - I don't. That's why I posted asking for help. You helped, and thanks for that. But it is NOT intuitively clear from ANY of the documentation that

            Sleep: "Sleep" [
                dwMilliseconds    [integer!]
]

also required the #import statement for kernel32.dll.

hiiamboris
@hiiamboris
@GiuseppeChillemi yeah, I intentionally fill the examples with tricks.. ☻
return from inside a context block works as if it was inside a function that gets executed, so in effect you get f: bound to the function! value
pick accepts a logic value as index, true is the 1st one, false is the 2nd
@burque505 it's in the link I gave you :)
you can check MS docs for in what dll what func resides https://docs.microsoft.com/en-us/windows/desktop/api/synchapi/nf-synchapi-sleep
hiiamboris
@hiiamboris
@burque505 for AHK you should consult their documention, I have no idea about this stuff, but pretty sure from common sense that "ahktextdll" is not a valid function name
GiuseppeChillemi
@GiuseppeChillemi
@hiiamboris , I'll tell you in italian language: "Disgraziato, mi stai facendo impazzire !!!"
So, this is the reason for ☻