English Amiga Board


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

 
 
Thread Tools
Old 21 November 2019, 12:39   #1
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 208
[blitz] moving the pointers around

Hi,
let's say I have 2 programs running (second one is being started from the 1st one)
let's say I need to pass an address of a new type from program 1 to program 2

I have following things declared in both programs:
Code:
NEWTYPE._thelist
  togo.w
...
END NEWTYPE

NEWTYPE._msg
  *tl._thelist
...
END NEWTYPE

DEFTYPE._thelist thelist ;<< this line in 2nd program: DEFTYPE._thelist *thelist
DEFTYPE._msg *msg
in 1st program I do:
Code:
*msg\tl=thelist
and send this message to the port of 2nd program

in 2nd program when the message comes i do:
Code:
*thelist=*msg\tl
Is that correct?
Why do I ask?
Because the second program's job is to update *thelist\togo value
and in the mean time 1st program is showing that value in GUI

And here I'm experiencing one problem because of:
Code:
*thelist\togo-1
Above line is located inside the loop and is executed more or less once per second (when the program gets the signal from MHI)
As long as I keep that line "active" (in 2nd program) and I try lets say move the icon on WB I get strange behavior - sometimes the mouse pointer just stops, then jumps to diffrernt place, the icon I'm dragging jumps to its original postion -but the \togo counter is counting correctly.
When I comment out that line all the dragging works great (but my program doesn't show updated information in that case)

So I suspect that I did something wrong with the pointers....
Thanks
peceha is offline  
Old 21 November 2019, 17:05   #2
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,450
I've only had a quick look, but something feels a little off... I think you need the address of the thelist in the first program to pass on. I'm not sure how Blitz resolves the root of a Newtype like that, but for a primitive variable type you would do it like this:

Code:
*msg\tl=&thelist
Also, I'm not sure setting up a Newtype field as a pointer works like that. It's not possible to reference it as a pointer later on, so there's no way to differentiate between a pointer and a variable. I would just use a longword and only ever consider the contents as an address - you would need to assign the address to a variable anyway to use the content I think (though I'm easily confused by pointers...)
Daedalus is offline  
Old 21 November 2019, 18:04   #3
peceha
Registered User

peceha's Avatar
 
Join Date: Dec 2017
Location: Poland
Age: 43
Posts: 208
Hi Daedalus,
thanks for your suggestions.
I think the pointers are handled correctly (I did some test and it worked)
And I think I found the problem...

Since there are 2 programs running at the same time it can happen that both of them try to access that variable at the same time.
I stopped the reading on the GUI side and the problem is gone.
So now I will be sending signals when it can be read and let's hope that will work
peceha is offline  
Old 21 November 2019, 19:11   #4
Daedalus
Registered User

Daedalus's Avatar
 
Join Date: Jun 2009
Location: Dublin, then Glasgow
Posts: 4,450
Ah, so it was some sort of race condition. Glad you've sorted it anyway!
Daedalus is offline  
Old 27 November 2019, 18:47   #5
Honitos
Registered User

 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 37
I guess for these kind of shared data between tasks amigaOS has "Semaphores".
You should look at these if it will be topic again.

Gesendet von meinem SM-G973F mit Tapatalk
Honitos is offline  
Old 27 November 2019, 20:17   #6
BippyM
Global Moderator

BippyM's Avatar
 
Join Date: Nov 2001
Location: Nottingham, UK
Age: 44
Posts: 8,941
Quote:
Originally Posted by Honitos View Post
I
Gesendet von meinem SM-G973F mit Tapatalk
Hi mate,

Please turn off automatic signatures in tapatalk. See the forum rules on signatures for more info.

Thanks
BippyM is offline  
Old 27 November 2019, 22:15   #7
Honitos
Registered User

 
Join Date: Nov 2019
Location: Celle / Germany
Posts: 37
Sorry for that!
Honitos is offline  
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Just a passing brain fart! Unkown OT - General 1 04 November 2019 14:13
Repeatable crashes with NEWTYPEs, Pointers and Strings (Blitz 2.1) betajaen Coders. Blitz Basic 12 07 August 2018 18:36
Passing parameters to a script via WBRun mfilos support.Other 18 14 January 2014 23:29
Passing arguments to scripts Leffmann Coders. General 4 23 January 2009 21:43
Norwegians passing thru OSLO? PLEASE READ :) AmiDelf Amiga scene 0 29 September 2003 16:11

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 07:45.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Page generated in 0.06597 seconds with 13 queries