How do I convert integer to cardinal on the fly?
Hi All, What am I doing wrong here? > my int16 $x = 0xABCD; -21555 > say $x.base(16); -5433 > my uint16 $y = $x.uint16; No such method 'uint16' for invocant of type 'Int' in block at line 1 Many thanks, -T
Re: How do I assign values to CArray[WCHAR]?
On 2020-01-06 22:02, ToddAndMargo via perl6-users wrote: Hi All, What am I doing wrong here? How do I assign values to CArray[WCHAR]? I want $lpData[0] to be 0xABCD and $lpData[1] to be 0xEF12. > use NativeCall; Nil > constant WCHAR := uint16; (uint16) This was the booboo. I forgot to initialize the array. It should have been: my CArray[WCHAR] $lpData = CArray[WCHAR].new() JJ helped me find it on Stack Overflow.
How do I assign values to CArray[WCHAR]?
Hi All, What am I doing wrong here? How do I assign values to CArray[WCHAR]? I want $lpData[0] to be 0xABCD and $lpData[1] to be 0xEF12. > use NativeCall; Nil > constant WCHAR:= uint16; (uint16) > my $ValueData = 0xABCDEF12; 2882400018 > my CArray[WCHAR] $lpData; (CArray[uint16]) > $lpData[ 0 ] = ( $ValueData +& 0x ) +> 0x10; Type check failed in assignment to $lpData; expected NativeCall::Types::CArray[uint16] but got Array ($[]) in block at line 1 > $lpData[ 1 ] =$ValueData +& 0x; Type check failed in assignment to $lpData; expected NativeCall::Types::CArray[uint16] but got Array ($[]) in block at line 1 Many thanks, -T
Re: How to process command line options
On 2020-01-05 14:32, David Santiago wrote: Hello. I'm following https://docs.raku.org/language/5to6-nutshell#Getopt::Long but i still haven't figured it out how do i use a constraint in a named parameter when processing a command line. I have this piece of code: multi sub MAIN("apt", :$layout where $layout ~~ /^<[12345]>\+[kk|1]$|^6\+$|^[studio|unusual]$/ #= Apartment layout. Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual ) { say "Enter"; } however when i run it i get the --help message: $ raku script.raku apt --layout '1+kk' Usage: script.raku [--layout=] apartment --layout=Apartment layout. Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual If i make layout a positional parameter then it works correctly. Is there a way to make this work with a named parameter? And how do i make possible to use the "--layout" option several times? Changing the parameter from $layout to @layout doesn't work. Best regards, David Santiago Hi David, This is probably not going to help, by maybe there will be something in it that will help. -T perl 6: How to parce values from the command line References: https://stackoverflow.com/questions/59112680/perl6-how-do-i-read-mixed-parameters-from-the-command-line https://modules.raku.org/dist/Getopt::Long:cpan:LEONT https://stackoverflow.com/questions/57041053/main-subroutine https://docs.raku.org/language/create-cli#index-entry-MAIN If you are only interested in parameters with a single dash, you'll need GetOpt::Long Here is an example using Getopt::Long: use v6; use Getopt::Long; my %opt = help => 0, 'r=s' => "", 'q=s' => "", "w=s" => ""; my %options = get-options(%opt).hash; say %options; Example run: $ p.p6 -w xyz -q def -r abc {help => 0, q => def, r => abc, w => xyz} -- Here is an example using Getopt::Long: use v6; use Getopt::Long; my %opt = help => 0, 'r=s' => "", 'q=s' => "", 'w=s' => ""; my %options = get-options(%opt).hash; say %options; say @*ARGS; Example run: $ p.p6 -w xyz -q def -r abc hello {help => 0, q => def, r => abc, w => xyz} [hello] ~ Use the MAIN sub: #!/usr/bin/env raku use v6; sub MAIN(:$these ="These", :$are="Are", :$params="Params") { say "$these $are $params"; } You can type these parameters in any order: ./command-line.p6 --are=well --these=those those well Params And will also catch any extra parameter, showing you the actual parameters: ./command-line.p6 --are=well --these=those --not=this_one Usage: ./command-line.p6 [--these=] [--are=] [--params=] If you are only interested in parameters with a single dash, you'll need GetOpt::Long
Re: My Native Call notes
On Mon, Jan 6, 2020, 09:01 ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: On 2020-01-05 22:56, ToddAndMargo via perl6-users wrote: > do they rise to the level of actually helping others? I am afraid I am annoying more than helping On 2020-01-05 23:20, Veesh Goldman wrote: This sort of thing should be in one repo, because it's one now project. And GitHub is non-intrusive, so it can't possibly annoy anyone. I am not ignoring you. I have a bunch of stuff I have to get caught up on before I can jump on this.
Re: How to process command line options
Thanks for the reply! That was the issue, the missing '=', and the order. I thought that because it was a named parameter the order wouldn't matter. Regarding the second question, on how to have the same switch multiple times, using a @ sigil doesn't work: Code: subset Layout of Str where * ~~ /^<[12345]>\+[kk|1]$|^6\+$|^[studio|unusual]$/; multi sub MAIN("apt", Layout :@layout! #= Apartment layout. Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual ) { say "enter!"; } When invoking: $> raku bin/script.raku --layout='unusual' --layout='1+kk' apt Usage: bin/script.raku --layout= ... apartment --layout= ...Apartment layout. Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual Unfortunately I'm unable to find any example in google on how to do this. I guess i will have to look for some module. Best regards, David Santiago Patrick Spek via perl6-users escreveu no dia segunda, 6/01/2020 à(s) 09:25: > > On Sun, 5 Jan 2020 22:32:02 + > David Santiago wrote: > > > Hello. > > > > I'm following > > https://docs.raku.org/language/5to6-nutshell#Getopt::Long but i still > > haven't figured it out how do i use a constraint in a named parameter > > when processing a command line. > > > > I have this piece of code: > > > > multi sub MAIN("apt", > > :$layout where $layout ~~ > > /^<[12345]>\+[kk|1]$|^6\+$|^[studio|unusual]$/ #= Apartment layout. > > Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual > > ) { > > say "Enter"; > > } > > > > however when i run it i get the --help message: > > > > $ raku script.raku apt --layout '1+kk' > > Usage: > > script.raku [--layout=] apartment > > > > --layout=Apartment layout. Values accepted: > > 1+kk,2+kk,...,5+kk, 6+, studio, unusual > > > > > > If i make layout a positional parameter then it works correctly. Is > > there a way to make this work with a named parameter? > > And how do i make possible to use the "--layout" option several times? > > Changing the parameter from $layout to @layout doesn't work. > > > > > > > > Best regards, > > David Santiago > > Hi David, > > The default parameter handling of Raku requires you to use an "=" sign > between the option name and value. Additionally, the option needs to be > before any positional arguments. Try running it as follows: > > raku script.raku --layout='1+kk' apt > > As for the ability to add it several times, I believe using an @ sigil > instead of a $ sigil should work, but perhaps someone else has spotted > an issue that I missed here. > > -- > With kind regards, > > Patrick Spek > > > www: https://www.tyil.nl/ > mail: p.s...@tyil.nl > pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 > > social: https://soc.fglt.nl/tyil > git:https://gitlab.com/tyil/
Re: rakudo.org outdated?
On 2020-01-06 1:18 a.m., Patrick Spek via perl6-users wrote: On Sun, 5 Jan 2020 18:27:01 -0800 Darren Duncan wrote: The normal Rakudo Star releases so far are compiled, [...] For Mac and Windows, perhaps, but the release is similar as it always was for GNU+Linux. And I'm mostly aiming for that since that's what I use (and also what I can test). Hence, I need people to verify they can make binaries for Windows and Mac (and actually do it as well) before I can continue. If your version requires users to run a Makefile or make or cc or whatever or have a working C compiler, then it is a source release and not the same thing. I never intended to make a "binary" release. I intended to make a Rakudo Star release, and I personally don't care if that'd be a binary or source. In the case of GNU+Linux, it's a source release. As long as we know what to expect. So it sounds like you're just making a single source release of Rakudo Star that users of any operating system would compile themselves, and not separate Linux/Mac/Win versions as had been the case before. In that case, I can do basic build testing on MacOS for you. I would just try following the same instructions as Linux users more or less. -- Darren Duncan
Re: How to process command line options
On Sun, 5 Jan 2020 22:32:02 + David Santiago wrote: > Hello. > > I'm following > https://docs.raku.org/language/5to6-nutshell#Getopt::Long but i still > haven't figured it out how do i use a constraint in a named parameter > when processing a command line. > > I have this piece of code: > > multi sub MAIN("apt", > :$layout where $layout ~~ > /^<[12345]>\+[kk|1]$|^6\+$|^[studio|unusual]$/ #= Apartment layout. > Values accepted: 1+kk,2+kk,...,5+kk, 6+, studio, unusual > ) { > say "Enter"; > } > > however when i run it i get the --help message: > > $ raku script.raku apt --layout '1+kk' > Usage: > script.raku [--layout=] apartment > > --layout=Apartment layout. Values accepted: > 1+kk,2+kk,...,5+kk, 6+, studio, unusual > > > If i make layout a positional parameter then it works correctly. Is > there a way to make this work with a named parameter? > And how do i make possible to use the "--layout" option several times? > Changing the parameter from $layout to @layout doesn't work. > > > > Best regards, > David Santiago Hi David, The default parameter handling of Raku requires you to use an "=" sign between the option name and value. Additionally, the option needs to be before any positional arguments. Try running it as follows: raku script.raku --layout='1+kk' apt As for the ability to add it several times, I believe using an @ sigil instead of a $ sigil should work, but perhaps someone else has spotted an issue that I missed here. -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 social: https://soc.fglt.nl/tyil git:https://gitlab.com/tyil/ pgpa8gnRdr_uA.pgp Description: OpenPGP digital signature
Re: rakudo.org outdated?
On Sun, 5 Jan 2020 18:27:01 -0800 Darren Duncan wrote: > The normal Rakudo Star releases so far are compiled, [...] For Mac and Windows, perhaps, but the release is similar as it always was for GNU+Linux. And I'm mostly aiming for that since that's what I use (and also what I can test). Hence, I need people to verify they can make binaries for Windows and Mac (and actually do it as well) before I can continue. > If your version requires users to run a Makefile or make or cc or > whatever or have a working C compiler, then it is a source release > and not the same thing. I never intended to make a "binary" release. I intended to make a Rakudo Star release, and I personally don't care if that'd be a binary or source. In the case of GNU+Linux, it's a source release. -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 social: https://soc.fglt.nl/tyil git:https://gitlab.com/tyil/ pgpf3peswg5dz.pgp Description: OpenPGP digital signature