Drawing ticks mark

Hello,

This code is wrote to draw tick mark along a left margin of canvas, unfortunately it does not work .
The code failed with the trace collection.
Need help to do it better.

[code]Dim trace as New Collection
Dim tick As Integer, size As Integer
Dim Lat_e as double
Dim Lat_Min,lat As Integer

Dim LPas,y,N,Xzero As Integer
Xzero =0

//Store data to draw, key=length of ticks : value= space between ticks mark

trace.Add(1,“1”)
trace.Add(5,“3”) //trace = [“1” : 1, “3”: 5, “4”: 30, “6”: 60]
trace.Add(30,“4”)

N=60
Lat_e =35
Lat_Min = Lat_e - N / 2
LPas = PBuffer.Graphics.Height / N

For lat = Ceil(Lat_Min) To Floor(Lat_Min) + N
y = (lat - Lat_Min) * LPas //between 0(+) and PBuffer.Height(-)

//Read the collection to draw …
For Each tick In Trace
If lat Mod tick = 0 Then
size =Trace.Key //return a key of collection, thus the length of tick mark
PBuffer.Graphics.DrawLine(XZero, y, XZero + size, y)
End if
Next
Next [/code]

What is pBUFFER? If it is a CANVAS, then you are correct, this won’t work, as all drawing to a Canvas must be done in the PAINT event

If pBufer is a PICTURE object , then I can’t see anything that slaps me in the face as to why it wouldnt draw “something”

[quote]

What is pBUFFER? If it is a CANVAS, then you are correct, this won’t work, as all drawing to a Canvas must be done in the PAINT event

If pBufer is a PICTURE object , then I can’t see anything that slaps me in the face as to why it wouldnt draw “something”[/quote]

With paint it seems like this :

Dim trace as New Collection
Dim tick , size, N As Integer

Dim Lat_Min As Integer, lat As Integer
Dim Lat_e as double
Dim LPas , y,  Xzero As Integer
Xzero =0

//Store data to draw,   key=length of ticks  :  value= space between ticks mark
trace.Add( 1,"1")
trace.Add(5, "3")                     // trace = ["1" : 1, "3": 5, "4": 30, "6": 60]
trace.Add(30,"4")

N=60
Lat_e =35
Lat_Min = Lat_e - N / 2
LPas = g.Height / N


For lat = Ceil(Lat_Min) To Floor(Lat_Min) + N
  y = (lat - Lat_Min) * LPas                                             'between 0(+) and  g.Height(-)
  
  'Read the collection to draw ...
  For Each tick In Trace
    If lat Mod tick = 0 Then
      size =Trace.key                                                     'return a key of collection, thus the length of tick mark
      g.DrawLine(XZero, y, XZero + size, y)                   'Draw horizontal Tick mark on left margin
    End if
  Next
Next

Output it looks like this :

[quote=335067:@Djamel AIT AMRANE]

Dim trace as New Collection [/quote]
Collection ?
This was deprecated ages ago

[quote]Collection ?
This was deprecated ages ago[/quote]
What do you mean ?
Any way, i need help to correct this code to run properly.

[quote=335158:@Norman Palardy]Collection ?
This was deprecated ages ago[/quote]
There is not a word about deprecated in the documentation.
http://documentation.xojo.com/index.php/Collection

From the documentation:

[quote=335210:@Paul Sondervan]There is not a word about deprecated in the documentation.
http://documentation.xojo.com/index.php/Collection[/quote]
nor it is listed here http://developer.xojo.com/deprecations
But the question already came up in the past: collections? - General - Xojo Programming Forum

To me, the only use case for Collections is when dealing with JSONItems: you can build up a nested structure of Dictionaries containing Collections in their keys and convert that to JSON Objects with embedded Arrays.

Many thanks for Antinio Rinaldi, this code us running and drawing tick marks in a margin with paint event.

[code]
Dim trace As New xojo.core.Dictionary
Dim tick , size, N As Integer
dim traceD as Xojo.Core.DictionaryEntry
Dim Lat_Min As Integer, lat As Integer
Dim Lat_e As Double
Dim LPas , y, Xzero As Integer
Xzero =0

//Store data to draw, key=length of ticks : value= space between ticks mark
'trace.Add( 1,“1”)
'trace.Add(5, “3”) // trace = [“1” : 1, “3”: 5, “4”: 30, “6”: 60]
'trace.Add(30,“4”)
trace.Value(1)=“1”
trace.Value(5)=“3”
trace.Value(30)=“4”

N=60
Lat_e =35
Lat_Min = Lat_e - N / 2
LPas = g.Height / N

For lat = Ceil(Lat_Min) To Floor(Lat_Min) + N
y = (lat - Lat_Min) * LPas 'between 0(+) and g.Height(-)

'Read the collection to draw …
for each traceD in trace
//For Each tick In Trace
tick=traceD.Key
If lat Mod tick = 0 Then
size =TraceD.key 'return a key of collection, thus the length of tick mark
g.DrawLine(XZero, y, XZero + size, y) 'Draw horizontal Tick mark on left margin
End If
Next
Next[/code]

[quote=335067:@Djamel AIT AMRANE]Hello,

This code is wrote to draw tick mark along a left margin of canvas, unfortunately it does not work .
The code failed with the trace collection.
Need help to do it better.

[code]Dim trace as New Collection
Dim tick As Integer, size As Integer
Dim Lat_e as double
Dim Lat_Min,lat As Integer

Dim LPas,y,N,Xzero As Integer
Xzero =0

//Store data to draw, key=length of ticks : value= space between ticks mark

trace.Add(1,“1”)
trace.Add(5,“3”) //trace = [“1” : 1, “3”: 5, “4”: 30, “6”: 60]
trace.Add(30,“4”)

N=60
Lat_e =35
Lat_Min = Lat_e - N / 2
LPas = PBuffer.Graphics.Height / N

For lat = Ceil(Lat_Min) To Floor(Lat_Min) + N
y = (lat - Lat_Min) * LPas //between 0(+) and PBuffer.Height(-)

//Read the collection to draw …
For Each tick In Trace
If lat Mod tick = 0 Then
size =Trace.Key //return a key of collection, thus the length of tick mark
PBuffer.Graphics.DrawLine(XZero, y, XZero + size, y)
End if
Next
Next [/code][/quote]