Re: [Jprogramming] J calling C++ SDL

2020-02-02 Thread Thomas McGuire
I happened to be playing around with SDL2 and J and came across your thread. 
While you probably got through your issues and don’t care any more, still, I 
thought I would complete the thread with an answer so future queries into the 
archive can provide some more detail to interested parties.

First the SDL2 tutorials at Gigi Labs seem to be easier to translate into J 
code than the Lazy foo tutorials. Find the tutorial to load a bitmap here:

http://gigi.nullneuron.net/gigilabs/displaying-an-image-in-an-sdl2-window/ 


Now the following code works on a MacBook Pro with Catalina loaded. I 
downloaded the SDL2 and built it and was able to bootstrap up calls into DLL 
from J. I have some issues with the way it works as I have to use take ({.) to 
grab the pointer I need from the result of a call to SDL2. There are also J 
boxing idiosyncrasies that mess with your pointers. 

So here’s the code to get the toucan bitmap that is in the addons/graphics/bmp 
directory into an SDL2 window:

load ‘path to SDL2.ijs’

NB. The following are defined in SDL2.ijs
NB. void=: 0$''
NB. null=: <0

SDL_Init  i i')

NB. extern DECLSPEC int SDLCALL SDL_InitSubSystem(Uint32 flags);
SDL_InitSubSystem =: (SDLDLL, ' SDL_InitSubSystem i i')

NB. extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
SDL_QuitSubSystem =: (SDLDLL, ' SDL_QuitSubSystem n i')

NB. extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
SDL_WasInit =: (SDLDLL, ' SDL_WasInit i i')

NB. extern DECLSPEC void SDLCALL SDL_Quit(void);
SDLQuit =: (SDLDLL, ' SDL_Quit n')


SDL_WINDOWPOS_UNDEFINED_MASK =: 16b1fff
SDL_WINDOWPOS_UNDEFINED =: SDL_WINDOWPOS_UNDEFINED_MASK +. 0

NB. extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title,
NB. int x, int y, int w,
NB. int h, Uint32 flags);
SDL_CreateWindow =: (SDLDLL, ' SDL_CreateWindow *  i i i i i')

NB. extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * 
window, int index, Uint32 flags);
SDL_CreateRenderer =: (SDLDLL, ' SDL_CreateRenderer * * i i')

SDL_SetRenderDrawColor =: (SDLDLL, ' SDL_SetRenderDrawColor n * i i i i')

SDL_RenderCopy =: (SDLDLL, ' SDL_RenderCopy n * * * *')

SDL_RenderClear =: (SDLDLL, ' SDL_RenderClear n *')

SDL_RenderPresent =: (SDLDLL, ' SDL_RenderPresent n *')

SDL_RenderDrawLine =: (SDLDLL, ' SDL_RenderDrawLine n * i i i i')
SDL_DestroyRenderer =: (SDLDLL, ' SDL_DestroyRenderer n *')
SDL_DestroyWindow =: (SDLDLL, ' SDL_DestroyWindow n *')
SDL_DestroyTexture =: (SDLDLL, ' SDL_DestroyTexture n *')
SDL_FreeSurface =: (SDLDLL, ' SDL_FreeSurface n *')

SDL_CreateTextureFromSurface =: (SDLDLL, ' SDL_CreateTextureFromSurface * * 
*')

SDL_GetWindowSurface =: (SDLDLL, ' SDL_GetWindowSurface * *')
SDL_RWFromFile =: (SDLDLL, ' SDL_RWFromFile * *c *c')
SDL_LoadBMP_RW =: (SDLDLL, ' SDL_LoadBMP_RW * * i')
SDL_BlitSurface =: (SDLDLL, ' SDL_UpperBlit > i * * * *')%cd




> On Aug 8, 2015, at 9:51 AM, Jon Hough  wrote:
> 
> Thanks,
> Yes, I will look into cder. 
> Regards,Jon
> 
>> Date: Sat, 8 Aug 2015 21:40:16 +0800
>> From: bbill@gmail.com
>> To: programm...@jsoftware.com
>> Subject: Re: [Jprogramming] J calling C++ SDL
>> 
>> I think your code will not work on 64-bit platforms. You need to figure out
>> which parameters will be 64-bit.
>> 
>> when using c, the c compiler will figure this out for you, but when using
>> J, you are on you own.
>> 
>> if cd raise domain error, cder'' will tell why is failed.
>> 
>> please study the j user manual.
>> 
>> I am really just experimenting here. SDL is a well known C/C++ media
>> library. https://www.libsdl.org/download-2.0.php
>> It is possible to use SDL for all kinds of things, but it is often used for
>> games and game prototyping.
>> This is a well known series of tutorials for SDL:
>> http://lazyfoo.net/tutorials/SDL/02_getting_an_image_on_the_screen/index.php
>> These functions need to be called first:
>> SDL_Init( SDL_INIT_VIDEO );
>> SDL_CreateWindow( "SDL Tutorial", SDL_WINDOWPOS_UNDEFINED,
>> SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
>> SDL_GetWindowSurface( gWindow );
>> SDL_CreateWindow and SDL_GetWindowSurface return pointers to SDL objects.
>> This is my J attempt at calling these functions:
>> 
>> load 'dll files'
>> 
>> 
>> lib =: '/path/to/libSDL2.so'
>> 
>> NB. takes an int, returns a pointer
>> 
>> SDL_Init =: 'SDL_Init i i'
>> 
>> NB. takes window title, dimensions and returns a pointer
>> 
>> SDL_CreateWindow =: 'SDL_CreateWindow i *c i i i i i'
>> 
>> NB. takes the previous pointer and returns a pointer to a window surface.
>> 
>> SDL_GetWindowSurface =: 'SDL_GetWindowSurface i x'
>> 
>> NB. Load a bitmap, needs the path to the bitmap
>> 
>> SDL_LoadBMP =: 'SDL_LoadBMP i *c'
>> 
>> 
>> initParams =: <0
>> 
>> cwParams =: 'DEMO';10;10;700;500;0
>> 
>> bmpParams =: <'path/to/bmp file'
>> 
>> 
>> call1 =: lib, ' ',SDL_Init
>> 
>> call2 =: lib,' ',SDL_CreateWindow
>> 
>> call3 =: 

Re: [Jprogramming] feature request: negative copy fill

2020-02-02 Thread Don Kelly

Why not this?

'  ',1j2#data   NB. 2 spaces in '' fixed width characters

a b r a c a d a b r a

3 ": i.~ data

0 1 2 0 4 0 6 0 1 2 0


Don Kelly



On 2020-02-02 2:15 a.m., Marshall Lochbaum wrote:

Assuming you want all fills to come before the corresponding element,
you can use:

1j2 #&.|. data
   a  b  r  a  c  a  d  a  b  r  a

I agree that fill-before is a reasonable interpretation for a negative
imaginary part, although I doubt J's complex replicate, or APL's expand,
are really the best way to deal with inserting fills (I don't have a
better one).

Marshall

On Sat, Feb 01, 2020 at 11:46:24AM -0500, David Lambert wrote:

data=:'abracadabra'

NB. whereas
1j_2 # data
|domain error
|   1j_2#data

NB. I've often wanted
_2 |. 1j2 # data
   a  b  r  a  c  a  d  a  b  r  a

NB. because it aligns with

3 ": i.~ data  NB. index from left
   0  1  2  0  4  0  6  0  1  2  0

3 ": i:~ data  NB. index from right
  10  8  9 10  4 10  6 10  8  9 10

duplicate =: (i: ~: i.)~
duplicate data
1 1 1 1 0 1 0 1 1 1 1
--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J701 for iPad

2020-02-02 Thread 'Jim Russell' via Programming


> On Feb 2, 2020, at 2:41 PM, Ian Clark  wrote:
> 
> Very interesting, Jim.
> 
> I too have been having difficulties with the keyboard when using j701 on my
> iPad. I'd like to know more.
> 
> I take it you are referring to: Settings: General > Keyboards. Are you
> saying that ScanPro altered settings without your knowledge, let alone
> consent? That's not a user-friendly thing for an App Store product to do.

I probably blamed ScanPro prematurely. The problem reappeared after I posted, 
but all is well again.

I do have a Bluetooth keyboard, a Logitech slim. When I later reattached that 
keyboard, the small keyboard reappeared, but the the large (workable) one was 
restored when I disconnected it.  

Looking some more, I also had the Microsoft "swipe" keyboard installed. (MS 
bought out "Swipe", and renamed it [something which i remembered a minute ago: 
WordFlow, thank you Safari History] and later discontinued it. When I first saw 
it in settings i could enable/disable full access to the developer, but was 
initially unable to remove it. Somehow, after looking it up in the App Store 
and doing a web search or two, it went away.  (My memory has a half life of 
about 30 seconds, sorry i can't be more specific.)

> Do you have a record of the "before" and "after" settings (after deleting
> ScanPro) – or can you try to remember what changed? Can you please pm me a
> screen shot of your present settings? (…will doubtless need 2 screen shots).
> 
Nope, sorry. I can take some screen shots of my settings and send then via 
email if you like.
> Have you played some more with those settings? What I mean to say is: are
> you confident your present settings yield the most satisfactory keyboard
> behaviour?
> 
Again yes and no, but for the nonce it seems to be again working.
> Do you own a hardware bluetooth keyboard?
Yes, a Logitech slim.
> When it's linked and working,
> does the on-screen keyboard disappear (as it should do)? It doesn't for me,
> at least not for j701.
> 
Usually yes, but the special J701 keyboard still shows, which is good for me, 
cause it makes entering special characters easier.  It seems I can use either, 
except that only the blue special J return key gets lines moved to the input 
area; the Bluetooth keyboard return does not. I cannot swipe on the special J 
keyboard, nor can I pinch it to the smaller size - but that is good! 

In the past I have seen (with j701) weirdness like left to right text input, 
random input characters, etc., which so far has stayed away now.

I also use my ipad (optionally with the keyboard) to remotely access my Mac 
Mini via the internet using  SplashTop. Frankly, I am amazed that anything 
keyboard related works at all!! For example, I can sit in McDonnalds, and 
restart the MacMini and watch it reboot from my ipad!
> Ian Clark
> 
>> On Sun, 2 Feb 2020 at 18:56, 'Jim Russell' via Programming <
>> programm...@jsoftware.com> wrote:
>> 
>> At some point in the various iOS 13 releases I feared I had lost j701 on
>> my iPad, although the iPhone version remained ok. On the iPad, the app

>> [snip]

>> What really hurts is that is in spite of a perfect 5 review rating, the
>> app has only 1 published review and only 6 reviews. And if you look in the
>> iPhone App Store, it is not even shown as having an iPad version.
>> 
>> If only prospective j programmers were smart enough to install the app and
>> use it enough to see the amazing power which the language offers...

>> 
> For information about J forums see http://www.jsoftware.com/forums.htm

--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] J701 for iPad

2020-02-02 Thread Ian Clark
Very interesting, Jim.

I too have been having difficulties with the keyboard when using j701 on my
iPad. I'd like to know more.

I take it you are referring to: Settings: General > Keyboards. Are you
saying that ScanPro altered settings without your knowledge, let alone
consent? That's not a user-friendly thing for an App Store product to do.

Do you have a record of the "before" and "after" settings (after deleting
ScanPro) – or can you try to remember what changed? Can you please pm me a
screen shot of your present settings? (…will doubtless need 2 screen shots).

Have you played some more with those settings? What I mean to say is: are
you confident your present settings yield the most satisfactory keyboard
behaviour?

Do you own a hardware bluetooth keyboard? When it's linked and working,
does the on-screen keyboard disappear (as it should do)? It doesn't for me,
at least not for j701.

Ian Clark

On Sun, 2 Feb 2020 at 18:56, 'Jim Russell' via Programming <
programm...@jsoftware.com> wrote:

> At some point in the various iOS 13 releases I feared I had lost j701 on
> my iPad, although the iPhone version remained ok. On the iPad, the app
> opened, but the special j keyboard opened in the reduced ("swipe" or quick
> path) size displaying only half of the full sized keys.
>
> To trouble shoot, I checked the keyboard settings and noted that a number
> of them were related to an (unused) ScanPro app. On a whim, I deleted that
> app, and the full sized j keyboard was restored. All now seems well!
>
> What really hurts is that is in spite of a perfect 5 review rating, the
> app has only 1 published review and only 6 reviews. And if you look in the
> iPhone App Store, it is not even shown as having an iPad version.
>
> If only prospective j programmers were smart enough to install the app and
> use it enough to see the amazing power which the language offers...
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


[Jprogramming] J701 for iPad

2020-02-02 Thread 'Jim Russell' via Programming
At some point in the various iOS 13 releases I feared I had lost j701 on my 
iPad, although the iPhone version remained ok. On the iPad, the app opened, but 
the special j keyboard opened in the reduced ("swipe" or quick path) size 
displaying only half of the full sized keys. 

To trouble shoot, I checked the keyboard settings and noted that a number of 
them were related to an (unused) ScanPro app. On a whim, I deleted that app, 
and the full sized j keyboard was restored. All now seems well!

What really hurts is that is in spite of a perfect 5 review rating, the app has 
only 1 published review and only 6 reviews. And if you look in the iPhone App 
Store, it is not even shown as having an iPad version. 

If only prospective j programmers were smart enough to install the app and use 
it enough to see the amazing power which the language offers...
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Android: whis is lowest version supported?

2020-02-02 Thread bill lam
It is very difficult to diagnosis for crash on start.
There is logcat output but users usually can't see it.
You may search for logcat in Google Play.

Sun, 02 Feb 2020, jprogramming написал(а):
> I have Samsung Note 3 SM-N9002 with Android 5.0.
> 
> This phone was created for the Chinese market, as it has 2 SIM cards.  But 
> the Android is original.
> 
>  Only everything Chinese is cut out of it.
> 
> bill lam :
> >It should work on all Android devices,
> >from android 2.3 to 9. Android 10 should have no problem but I didn't try.
> >
> >And it supports all cpu architect from
> > 32 bit armv5 to 64 bit armv8
> >x86 and x64 atom cpu.
> >
> >Is your phone genuine android OS or other Chinese versions?
> >
> >
> >On Mon, Feb 3, 2020, 12:22 AM 'Сергей Каменев' via Programming <
> >programm...@jsoftware.com > wrote:
> >
> >> Hi!
> >>
> >> I have phone with Android 5.0.
> >>
> >> Apk was installed, but crash when I trying to run J.
> >>
> >> I read in Wiki about working J on Android 4.X.
> >>
> >> Thank you!
> >> Sergey
> >> --
> >> For information about J forums see  http://www.jsoftware.com/forums.htm
> >>
> >--
> >For information about J forums see  http://www.jsoftware.com/forums.htm
> 
> 
> -- 
> Сергей Каменев
> --
> For information about J forums see http://www.jsoftware.com/forums.htm

-- 
regards,

GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --armor --export 4434BAB3
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Android: whis is lowest version supported?

2020-02-02 Thread 'Сергей Каменев' via Programming
I have Samsung Note 3 SM-N9002 with Android 5.0.

This phone was created for the Chinese market, as it has 2 SIM cards.  But the 
Android is original.

 Only everything Chinese is cut out of it.

bill lam :
>It should work on all Android devices,
>from android 2.3 to 9. Android 10 should have no problem but I didn't try.
>
>And it supports all cpu architect from
> 32 bit armv5 to 64 bit armv8
>x86 and x64 atom cpu.
>
>Is your phone genuine android OS or other Chinese versions?
>
>
>On Mon, Feb 3, 2020, 12:22 AM 'Сергей Каменев' via Programming <
>programm...@jsoftware.com > wrote:
>
>> Hi!
>>
>> I have phone with Android 5.0.
>>
>> Apk was installed, but crash when I trying to run J.
>>
>> I read in Wiki about working J on Android 4.X.
>>
>> Thank you!
>> Sergey
>> --
>> For information about J forums see  http://www.jsoftware.com/forums.htm
>>
>--
>For information about J forums see  http://www.jsoftware.com/forums.htm


-- 
Сергей Каменев
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] Android: whis is lowest version supported?

2020-02-02 Thread bill lam
It should work on all Android devices,
from android 2.3 to 9. Android 10 should have no problem but I didn't try.

And it supports all cpu architect from
 32 bit armv5 to 64 bit armv8
x86 and x64 atom cpu.

Is your phone genuine android OS or other Chinese versions?


On Mon, Feb 3, 2020, 12:22 AM 'Сергей Каменев' via Programming <
programm...@jsoftware.com> wrote:

> Hi!
>
> I have phone with Android 5.0.
>
> Apk was installed, but crash when I trying to run J.
>
> I read in Wiki about working J on Android 4.X.
>
> Thank you!
> Sergey
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
For information about J forums see http://www.jsoftware.com/forums.htm


[Jprogramming] Android: whis is lowest version supported?

2020-02-02 Thread 'Сергей Каменев' via Programming
Hi!

I have phone with Android 5.0.

Apk was installed, but crash when I trying to run J.

I read in Wiki about working J on Android 4.X.

Thank you!
Sergey
--
For information about J forums see http://www.jsoftware.com/forums.htm


Re: [Jprogramming] feature request: negative copy fill

2020-02-02 Thread Marshall Lochbaum
Assuming you want all fills to come before the corresponding element,
you can use:

   1j2 #&.|. data
  a  b  r  a  c  a  d  a  b  r  a

I agree that fill-before is a reasonable interpretation for a negative
imaginary part, although I doubt J's complex replicate, or APL's expand,
are really the best way to deal with inserting fills (I don't have a
better one).

Marshall

On Sat, Feb 01, 2020 at 11:46:24AM -0500, David Lambert wrote:
>data=:'abracadabra'
> 
>NB. whereas
>1j_2 # data
> |domain error
> |   1j_2#data
> 
>NB. I've often wanted
>_2 |. 1j2 # data
>   a  b  r  a  c  a  d  a  b  r  a
> 
>NB. because it aligns with
> 
>3 ": i.~ data  NB. index from left
>   0  1  2  0  4  0  6  0  1  2  0
> 
>3 ": i:~ data  NB. index from right
>  10  8  9 10  4 10  6 10  8  9 10
> 
>duplicate =: (i: ~: i.)~
>duplicate data
> 1 1 1 1 0 1 0 1 1 1 1
> --
> For information about J forums see http://www.jsoftware.com/forums.htm
--
For information about J forums see http://www.jsoftware.com/forums.htm