English Amiga Board


Go Back   English Amiga Board > Coders > Coders. Language > Coders. Blitz Basic

 
 
Thread Tools
Old 14 January 2018, 10:29   #61
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 41
Posts: 16
Thanks!
Now it is not magic anymore
peceha is online now  
AdSense AdSense  
Old 16 January 2018, 19:38   #62
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 41
Posts: 16
Hello
Two basic questions:

1. is it possible to pass a list to a function as an argument?

2. is it possible to declare a list within a function?
When I try to do this inside the function i get error "ARRAY IS NOT A LIST":
Code:
NEWTYPE.myType
 a.b
 b
 c
End NEWTYPE
Dim List lista.myType(100)
If AddItem(lista()) Then lista()\a=1 ;here the error shows up
When i move NEWTYPE...End NEWTYPE and DIM outside the function everything is working fine

Thanks.


EDIT
3.What is going on here:
Code:
NEWTYPE.bspArea
 c.b
 r
 w
 h
End NEWTYPE

Statement test{c,r,w,h}
 nPrint c," ",r," ",w," ",h
 ;DEFTYPE.bspArea panel    ;<- when i uncomment this line strange results are showing
End Statement

test{0,0,10,10}
MouseWait
End
without DEFTYPE: 0 0 10 10
with DEFTYPE: 0 0 10.9997 10

Last edited by peceha; 16 January 2018 at 22:39.
peceha is online now  
Old 16 January 2018, 23:54   #63
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,376
1: Not that I know of. You can use the Shared keyword to allow the procedure to access the same list as the main program. Newtypes can be passed as a pointer, but I don't think lists can be assigned to pointers so I don't think passing a list is possible. Maybe someone else knows a way though?

2: No, only indexed arrays can be declared within a function. As before however, you can use a global list with the Shared keyword, so long as you remember to clear it each time and don't do any recursion.

3: Hmmm, looks like a bug. What version of Blitz are you using? I vaguely remember in the AmiBlitz changenotes that there was a fix for some bug in parameter passing that you may have stumbled upon. It looks like a mismatch of types that's not getting picked up by the compiler / debugger. I would suggest always declaring types for parameters like that, and that should avoid the problem:

Statement test{c.b, r.b, w.b, h.b}
Daedalus is offline  
Old 17 January 2018, 00:07   #64
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 41
Posts: 16
ad.3
Im using BB2 release 2.1, TED v2.24

When I replace Statement test{c,r,w,h,} with:
..{c.b, r.b, w.b, h.b} then i have 0 0 -8 10
..{c.w, r.w, w.w, h.w} then i have 0 0 -12 10
..{c.l, r.l, w.l, h.l} then i have 0 0 65516 10
peceha is online now  
Old 17 January 2018, 10:44   #65
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 2,376
Hmmm, that's very weird. There appears to be an extra byte or something assigned to the 3rd parameter. I would use a later version of Blitz 2 fro a start, see if that fixes the problem. The Ultimate Blitz Basic CD has a later version, and other updates are available from Blitz-2000.co.uk.
Daedalus is offline  
Old 17 January 2018, 10:54   #66
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 41
Posts: 16
Thanks for help.
You were right about a bug:
Quote:
3rd parameter bugfix" Fixes an important and serious bug in the passing of the third parameter to functions.
I'll try to update everything now.

Thank you.
peceha is online now  
Old Today, 00:10   #67
E-Penguin
Banana

 
Join Date: Jul 2016
Location: Darmstadt
Posts: 414
If there an equivalent of If ... Else If ... Else?

I've tried "Else If" "Elseif" and "Elsif" but it doesn't like any of them. There must be a way, surely?
E-Penguin is offline  
AdSense AdSense  
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blitz basic 2 Help Havie Coders. Blitz Basic 30 08 September 2013 10:15
blitz basic petza request.Apps 11 08 April 2007 02:49
Blitz Basic 2 anyone? jobro request.Apps 12 28 November 2005 19:15
Blitz Basic StopCD32 Tony Landais Coders. General 2 08 May 2003 23:51
Blitz Basic 2 LaundroMat Retrogaming General Discussion 5 24 July 2001 09:10

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 11:35.


Powered by vBulletin® Version 3.8.8 Beta 1
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Page generated in 0.16939 seconds with 13 queries