Beijer Electronics (formerly QSI Corporation)

Manufacturer of Mobile Data and Human Machine Interface Terminals.
It is currently Wed Nov 22, 2017 5:33 am

All times are UTC - 7 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: DataGrid Error
PostPosted: Sat May 13, 2006 1:01 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
This is a tough one. I dont get an error when RED[x] is changed to 1 during a button or slider press. But when the project boots and the RED[x]=1 which is set from reading a file the code will crash.







This is a line located in serval places in the project. When RED[x] = 0 all works well. When RED[x]=1 I get an error.



DataGrid_1.SetCellText (1, 2, "R:" + str(RED[Fixture+SceneNumber]))





Error:

15:57:40 13 May2006 #98(severity5)

Interpreter: Illegal index into an Array







Error Location:



Quote:



func SetCellText (row as integer, col as integer, newData as charstr)

dim idx as integer



if (row < 0) or (row >= numRows) or (col < 0) or (col >= numColumns) then

return

endif



idx = row * numColumns+col

FreeArrayHandle(data[idx])' Error Here

data[idx] := AllocateArrayHandle(newData)



'if (row == curRow) and (col == curCol) then

'curCellText := data

'endif



Rerender(me)

endfunc











Top
 Profile  
 
 Post subject:
PostPosted: Sat May 13, 2006 1:20 pm 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
UPDATE:





I assume this might be a initialization problem so I tried a little routine. It worked but is there a better way ?





func Startup ()



handles MSG_INIT



load=false 'disable DataGrid Cell Write



RED[0]=slider_r.value

load=true

userdirectmsg(default, _msg_post_init, 0, false)

return

endfunc





'///// SLIDER Changed

func ValueChanged()

RED[Fixture+SceneNumber]=slider_r.value

'// Updata Date GRID



if load then

DataGrid_1.SetCellText (1, 2, "R:" + str(RED[Fixture+SceneNumber]))

endif



endfunc



;// HERE I LOAD DATA GRID WITH BOOT VALUES

func PostStartup(dmy as integer) returns boolean

handles _msg_post_init

DataGrid_1.SetCellText (1, 0, "Fixture:" + str(Fixture))

DataGrid_1.SetCellText (1, 1, "Scene:" + str(SceneSelect))

DataGrid_1.SetCellText (1, 2, "R:" + str(RED[Fixture+SceneNumber]))

DataGrid_1.SetCellText (1, 3, "G:" + str(GREEN[Fixture+SceneNumber]))

DataGrid_1.SetCellText (1, 4, "b:" + str(BLUE[Fixture+SceneNumber]))

return true

endfunc


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 15, 2006 6:41 am 
Offline
QSI Support
QSI Support
User avatar

Joined: Wed Mar 08, 2006 12:25 pm
Posts: 881
Location: Salt Lake City, Utah
You are probably correct -- it is an initialization problem. Many objects require that they be initialized before you can call methods to modify them. The _MSG_POST_INIT trick you used is one we commonly use. For the DataGrid in particular, however, you can use the grid's Initialize event instead of _MSG_POST_INIT to setup the initial contents.

_________________
Jeremy
http://www.beijerinc.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 15, 2006 8:16 am 
Offline

Joined: Mon May 01, 2006 3:27 pm
Posts: 60
Thanx.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 7 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group