type conversions/Conversion Codes
34 posts
• Page 3 of 4 • 1, 2, 3, 4
Re: type conversions/Conversion Codes
Hi Vince,
OO is second nature to you young guys. It was invented when I was already at mid-career and has always seemed like overkill for the small projects I actually do. I am studying the Object Reference however. There is SO much good stuff in there!
-Stu
OO is second nature to you young guys. It was invented when I was already at mid-career and has always seemed like overkill for the small projects I actually do. I am studying the Object Reference however. There is SO much good stuff in there!
-Stu
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: type conversions/Conversion Codes
Stu wrote:OO is second nature to you young guys. It was invented when I was already at mid-career...
Actually, OO was invented at more or less the same time as APL: https://en.wikipedia.org/wiki/Simula. And although some would say it took a while to become popular, one could also argue that it caught on a bit quicker than APL - we're still working on that ;-)
I agree OO is overkill for many projects, but in my experience it is a pretty good tool of thought or interfaces between different components.
-
Morten|Dyalog - Posts: 394
- Joined: Tue Sep 09, 2008 3:52 pm
Re: type conversions/Conversion Codes
I use the following function to write a bitmap to a .bmp file:
bits writebmp file
'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴0 0 0 255 255 255))
bm.File←mypath,file
2 ⎕NQ'bm' 'FileWrite'
If I try to read the file back in with the following function, I get either a VALUE ERROR or a DOMAIN ERROR, depending on whether or not I use parentheses:
argb←mypath readbmp file
bmp←⎕WC 'bitmap' (mypath,file,'.bmp')
bits←bmp.Cbits
⎕EX 'bmp'
argb←256 256 256⊤bits
file='test'
mypath='C:\Users\Stuart Smith\Desktop\'
I'm obviously doing something wrong, but I can't see it.
bits writebmp file
'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴0 0 0 255 255 255))
bm.File←mypath,file
2 ⎕NQ'bm' 'FileWrite'
If I try to read the file back in with the following function, I get either a VALUE ERROR or a DOMAIN ERROR, depending on whether or not I use parentheses:
argb←mypath readbmp file
bmp←⎕WC 'bitmap' (mypath,file,'.bmp')
bits←bmp.Cbits
⎕EX 'bmp'
argb←256 256 256⊤bits
file='test'
mypath='C:\Users\Stuart Smith\Desktop\'
I'm obviously doing something wrong, but I can't see it.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: type conversions/Conversion Codes
Hi,
a little bit editing is needed:
i.e. the object name was missing (assign does not work here the way you expected) and the property name was mistyped (they are case-sensitive)
Yours
- Veli-Matti
a little bit editing is needed:
argb←mypath readbmp file;bmp
'bmp'⎕WC'Bitmap'(mypath,file,'.bmp')
argb←256 256 256⊤bmp.CBits
i.e. the object name was missing (assign does not work here the way you expected) and the property name was mistyped (they are case-sensitive)
Yours
- Veli-Matti
- Veli-Matti
- Posts: 56
- Joined: Sat Nov 28, 2009 3:12 pm
Re: type conversions/Conversion Codes
Aha! It all works now. Thanks!
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: type conversions/Conversion Codes
I've been using the following function to write bitmaps to .bmp files:
bits writebmp file
'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴255 255 255 0 0 0))
bm.File←mypath,file
2 ⎕NQ'bm' 'FileWrite'
It works fine, but now every time I launch APL, I get a message to the effect that the object #.bm cannot be rebuilt. This does not prevent me from using the workspace, but it's clear I should be doing something so that I don't get that message. What is it that I should be doing?
bits writebmp file
'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴255 255 255 0 0 0))
bm.File←mypath,file
2 ⎕NQ'bm' 'FileWrite'
It works fine, but now every time I launch APL, I get a message to the effect that the object #.bm cannot be rebuilt. This does not prevent me from using the workspace, but it's clear I should be doing something so that I don't get that message. What is it that I should be doing?
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: type conversions/Conversion Codes
You could set bm.KeepBits to 1, so that the bits are saved in the workspace. But better may be to simply localise bm in your function, so that nothing of the Bitmap bm is retained in the saved workspace provided that you don't save the workspace with writemp in a suspended state ..
-
AndyS|Dyalog - Posts: 234
- Joined: Tue May 12, 2009 6:06 pm
Re: type conversions/Conversion Codes
Hi Stu,
You're getting this message as Dyalog is trying to recreate the bitmap from the file specified in the File property, but the file no longer exists.
If you set KeepBits on bm to 1, we will keep the image information of the bitmap in the workspace and you won't have to create it each time.
Alternatively, before you save the workspace, you can ⎕ex '#.bm'
This erases the bm object.
If you don't need to keep bm and intend it to be purely temporary, you can localize it at the top of writebmp and it will be erased when writebmp finishes.
e.g.
Regards,
Vince
You're getting this message as Dyalog is trying to recreate the bitmap from the file specified in the File property, but the file no longer exists.
If you set KeepBits on bm to 1, we will keep the image information of the bitmap in the workspace and you won't have to create it each time.
'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴255 255 255 0 0 0))('keepbits' 1)
Alternatively, before you save the workspace, you can ⎕ex '#.bm'
This erases the bm object.
If you don't need to keep bm and intend it to be purely temporary, you can localize it at the top of writebmp and it will be erased when writebmp finishes.
e.g.
∇ bits writebmp file;bm
[1] 'bm'⎕WC'bitmap'('Bits'bits)('Cmap'(2 3⍴255 255 255 0 0 0))
[2] bm.File←mypath,file
[3] 2 ⎕NQ'bm' 'FileWrite'
∇
Regards,
Vince
- Vince|Dyalog
- Posts: 335
- Joined: Wed Oct 01, 2008 9:39 am
Re: type conversions/Conversion Codes
Duh! Why didn't I think of that?
Thanks!
Is there a place where you can learn about OO in Dyalog? "Mastering APL" seems not to mention it, and the "Object Reference" assumes you already know all about OO programming. I used "old" APL in the late 1970's, before OO had been added to the language. My instinct is to write code in that obsolete style.
Thanks!
Is there a place where you can learn about OO in Dyalog? "Mastering APL" seems not to mention it, and the "Object Reference" assumes you already know all about OO programming. I used "old" APL in the late 1970's, before OO had been added to the language. My instinct is to write code in that obsolete style.
- Stu
- Posts: 97
- Joined: Thu Dec 31, 2015 1:30 am
Re: type conversions/Conversion Codes
In your Dyalog installation under the Help Menu / Documentation Center / there should be
Tutorials
Object Oriented Programming for APL Programmers
Object Oriented Programming for Impatient APL Programmers
DYALOG.NET Unicode Tutorial (requires IIS)
- - -
online I found:
http://help.dyalog.com/14.1/
under Programmer's Guide - Object Oriented Programming
HTH
/JoHo
PS:
I think, that in general the classic APL style is still very useful in many application cases. I think of OO as a method of organizing or packaging APL code in a compatible way to the rest of the world.
Tutorials
Object Oriented Programming for APL Programmers
Object Oriented Programming for Impatient APL Programmers
DYALOG.NET Unicode Tutorial (requires IIS)
- - -
online I found:
http://help.dyalog.com/14.1/
under Programmer's Guide - Object Oriented Programming
HTH
/JoHo
PS:
I think, that in general the classic APL style is still very useful in many application cases. I think of OO as a method of organizing or packaging APL code in a compatible way to the rest of the world.
-
JoHo - Posts: 27
- Joined: Sat Nov 28, 2009 12:51 pm
- Location: Austria, EU
34 posts
• Page 3 of 4 • 1, 2, 3, 4
Who is online
Users browsing this forum: No registered users and 1 guest
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group