libhs.log.DEMO
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © GETpacman

//@version=5
indicator("libhs.logger.DEMO", overlay=true)
plot(na)
import GETpacman/logger/3    as logger
import GETpacman/libhs_td4/3 as td4
import GETpacman/libhs_td5/3 as td5

color c_cream   =color.new(#c29857,20)

ip_consoleFirst =input.bool(true,'Test Console First?')

ip_uat_show=true
ip_uat_pos             = input.string  ('Bottom Right','Position',      inline='22', group='UAT',   options=['Top Left','Top Center','Top Right','Middle Left','Middle Center','Middle Right','Bottom Left','Bottom Center','Bottom Right'])
ip_uat_width           = input.int     (80,      'Width',               inline='22', group='UAT',   minval=20, maxval=400, step=10)
ip_uat_hsize           = input.string  ('Auto',  'UAT Header',          inline='25', group='UAT', options=['Auto','Tiny','Small','Normal','Large','Huge'])
ip_uat_hhalign         = input.string  ('Left',  'HA',                  inline='25', group='UAT', options=['Left','Center','Right'])
ip_uat_hvalign         = input.string  ('Top',   'VA',                  inline='25', group='UAT', options=['Top','Center','Bottom'])
ip_uat_tsize           = input.string  ('Auto',  'UAT   Text',          inline='26', group='UAT',  options=['Auto','Tiny','Small','Normal','Large','Huge'])
ip_uat_thalign         = input.string  ('Left',  'HA',                  inline='26', group='UAT', options=['Left','Center','Right'])
ip_uat_tvalign         = input.string  ('Top',   'VA',                  inline='26', group='UAT', options=['Top','Center','Bottom'])
pos_uat        = ip_uat_pos.getTablePosition()
hsize_uat      = ip_uat_hsize.getTextSize()
hhalign_uat    = ip_uat_hhalign.getTextAlign()
hvalign_uat    = ip_uat_hvalign.getTextAlign()
tsize_uat      = ip_uat_tsize.getTextSize()
thalign_uat    = ip_uat_thalign.getTextAlign()
tvalign_uat    = ip_uat_tvalign.getTextAlign()

var int maxLog=5
var int __colors=36
var demo = logger.log.new()
demo.init(maxLog, ip_consoleFirst? true:false)

var consoleBus    = matrix.new<string>(500,40,'')
var logxBus    = matrix.new<string>(500,40,'')

TsizeSmall='small'
TsizeNormal='normal'
L_bottom_center='bottom center'

td4.fill(consoleBus,fillData=barstate.isfirst)    
td5.fill(logxBus,fillData=barstate.isfirst)    

int devcolmsg=2, int devcollevelC=3, int devcolstatusC=4, int prodcolmsg=5, int prodcollevelC=6, int prodcolstatusC=7
int devcolm1=8, int devcolm2=9, int devcolm3=10, int devcolm4=11, int devcolm5=12, int devcolm6=13, int devcollevelL=14, int devcolstatusL=15
int prodcolm1=16, int prodcolm2=17, int prodcolm3=18, int prodcolm4=19, int prodcolm5=20, int prodcolm6=21, int prodcollevelL=22, int prodcolstatusL=23

var string o_skiplog = '^skip^'

color c_fuchsia_t100    = color.new(color.fuchsia,0)
color c_fuchsia_t65     = color.new(color.fuchsia,35)
color c_fuchsia_t35     = color.new(color.fuchsia,65)
color c_olive_t100    = color.new(color.olive,0)
color c_olive_t65     = color.new(color.olive,35)
color c_olive_t35     = color.new(color.olive,65)
color c_maroon_t100    = color.new(color.maroon,0)
color c_maroon_t65     = color.new(color.maroon,35)
color c_maroon_t35     = color.new(color.maroon,65)
color c_navy_t100    = color.new(color.navy,0)
color c_navy_t65     = color.new(color.navy,35)
color c_navy_t35     = color.new(color.navy,65)


color[] customFG=array.new_color()
color[] customHC=array.new_color()

array.push(customFG,color.orange), array.push(customHC,color.white)
array.push(customFG,c_fuchsia_t100), array.push(customHC,color.white)
array.push(customFG,c_fuchsia_t65), array.push(customHC,color.white)
array.push(customFG,c_olive_t100), array.push(customHC,color.white)
array.push(customFG,c_olive_t65), array.push(customHC,color.white)
array.push(customFG,c_maroon_t100), array.push(customHC,color.white)
array.push(customFG,c_maroon_t65), array.push(customHC,color.white)
array.push(customFG,c_navy_t100), array.push(customHC,color.white)
array.push(customFG,c_navy_t65), array.push(customHC,color.white)

array.push(customFG,c_fuchsia_t35), array.push(customHC,color.white)
array.push(customFG,c_olive_t35), array.push(customHC,color.white)
array.push(customFG,c_maroon_t35), array.push(customHC,color.white)
array.push(customFG,c_navy_t35), array.push(customHC,color.white)

int offsetErrorBars=1

var int xbarFinalTestDone=318+9
var int cbarFinalTestDone=321
var int abarFinalTestDone=28


var int totalFinalTestDone=xbarFinalTestDone+cbarFinalTestDone+abarFinalTestDone

int zidx=bar_index>(offsetErrorBars-1)?(((bar_index-offsetErrorBars)%totalFinalTestDone)+1):0

int idza= zidx - cbarFinalTestDone - xbarFinalTestDone
int idzc= (idza > 0) ? (cbarFinalTestDone+idza) : (zidx - (ip_consoleFirst ? 0 : xbarFinalTestDone))
int idzx= (idza > 0) ? (xbarFinalTestDone+idza) : (zidx - (ip_consoleFirst ? cbarFinalTestDone : 0))


var int zx=0
var int zc=0
var int za=0
var int czx=0
var int czc=0
var int cza=0

bool showLogx   = ip_uat_show and bar_index>(offsetErrorBars-1)         and (idzx>=1 and idzx<=xbarFinalTestDone)
bool showConsole= ip_uat_show and bar_index>(offsetErrorBars-1)         and (idzc>=1 and idzc<=cbarFinalTestDone)
bool showAttachedConsole=ip_uat_show and bar_index>(offsetErrorBars-1)  and ((idza>=1 and idza<=5) or (idza>=26 and idza<=abarFinalTestDone)) and zidx>=(totalFinalTestDone-(xbarFinalTestDone+cbarFinalTestDone))
bool consoleAttached=ip_uat_show and bar_index>(offsetErrorBars-1)  and (idza>5 and idza<26) and zidx>=(totalFinalTestDone-(xbarFinalTestDone+cbarFinalTestDone))

gm='', gm1='', gm2='', gm3='', gm4='', gm5='', gm6='', gs=''
dbmsg='', dbLevelC='', dbStatusC=''
dbm1='', dbm2='', dbm3='', dbm4='', dbm5='', dbm6='', dbLevelL='', dbStatusL=''

//______ == ______________________________ TESTING Logx

if idzx==1 or barstate.isfirst
    zx:=1
    demo.IsConsole:=false
    demo.clear()
    demo.resize(maxLog)
    demo.resetFrameColor()
    demo.PageOnEveryBar  := false
    demo.MoveLogUp       := true
    demo.ColorText       := false
    demo.HighlightText   := false
    demo.ShowBarIndex    := false
    demo.ShowDateTime    := false
    demo.ShowLogLevels   :=false
    demo.ReplaceWithCodes:=false
    demo.ShowHeader      := true
    demo.HeaderAtTop     := true
    demo.StatusBarAtBottom := true
    demo.ShowStatusBar   := true
    demo.ShowMetaStatus  := true
    demo.ShowQ1:=true, demo.ShowQ2:=true, demo.ShowQ3:=true, demo.ShowQ4:=true, demo.ShowQ5:=true, demo.ShowQ6:=true
    demo.TabSizeQ1:=0, demo.TabSizeQ2:=0, demo.TabSizeQ3:=0, demo.TabSizeQ4:=0, demo.TabSizeQ5:=0, demo.TabSizeQ6:=0
    demo.HeaderQ1:='logx.q1', demo.HeaderQ2:='logx.q2', demo.HeaderQ3:='logx.q3', demo.HeaderQ4:='logx.q4', demo.HeaderQ5:='logx.q5', demo.HeaderQ6:='logx.q6' 
    demo.AutoMerge       := true
    demo.dateTimeFormat('dd.MMM.yy HH:mm')
    demo.FrameColor      :=color.green
    demo.MarkNewBar      := false
    demo.PageHistory     := 0
    demo.RestrictLevelsToKey7  := false
    demo.MinWidth        := 80
    demo.StatusTooltip   :='Logx Testing'
    demo.ShowMinimumLevel:= 0

czx+=1
if idzx==1 or idzx==61 or idzx==73 or idzx==85 or idzx==96 or idzx==123  or idzx==203  or idzx==243  or idzx==245  or idzx==246  or idzx==304 or idzx==310 or idzx==320
    czx:=0
if idzx==305
    czx:=8
ezx=((czx-1)%__colors)+1

switch(idzx)  //Prep resize and clear
    66  =>  demo.resize(12)
    133 =>  demo.resize(5)
    142 =>  demo.clear()
    // 152 =>  demo.clear()
    154 =>  demo.clear()
    167 =>  demo.resize(6)
    168 =>  demo.resize(5)
    170 =>  demo.resize(15)
    198 =>  demo.clear()
    207 =>  demo.resize(11)
    231 =>  demo.resize(20)
    242 =>  demo.resize(11)
    245 =>  demo.resize(12)
    247 =>  demo.resize(10)
    278 =>  demo.resize(7)
    302 =>  demo.clear(), demo.resize(15)
    308 =>  demo.resize(18)


switch(idzx)  //PreCalls #1
    18  =>  demo.resetFrameColor()
    70  =>  demo.ColorText          := false
    82  =>  demo.HighlightText      := false
    93  =>  demo.ColorText          := false
    104 =>  demo.HighlightText      := false
    129 =>  demo.StatusBarAtBottom  := true
    134 =>  demo.HeaderAtTop        := true
    142 =>  demo.StatusBarAtBottom  := false
    154 =>  demo.MoveLogUp          := true
    162 =>  demo.dateTimeFormat()
    167 =>  demo.PageHistory        := 0
    173 =>  demo.PageOnEveryBar     := false
    184 =>  demo.AutoMerge          := false
    186 =>  demo.PageHistory        := 0
    192 =>  demo.AutoMerge          := false
    198 =>  demo.ShowQ1:=true, demo.ShowQ2:=true, demo.ShowQ3:=true, demo.ShowQ4:=true, demo.ShowQ5:=true, demo.ShowQ6:=true 
    210 =>  demo.AutoMerge          := true
    211 =>  demo.TabSizeQ1:=0, demo.TabSizeQ2:=0, demo.TabSizeQ3:=0
    228 =>  demo.ShowStatusBar      := true
    229 =>  demo.ShowBarIndex       := false
    234 =>  demo.MarkNewBar         := false
    240 =>  demo.MinWidth           := 80
    247 =>  demo.RestrictLevelsToKey7     := false
    255 =>  demo.ShowBarIndex       := false
    304 =>  demo.ColorText          := true
    305 =>  demo.ColorText          := false
    308 =>  demo.ShowMinimumLevel   := 0

switch(idzx)  //Prep Calls #2
    154 =>  demo.StatusBarAtBottom  := true
    165 =>  demo.ShowDateTime       := false
    228 =>  demo.ShowMetaStatus     := true
    240 =>  demo.ShowBarIndex       := true
    279 =>  demo.ColorText          := true
    300 =>  demo.ColorText          := false
    321 =>  demo.ColorText          := true
    322 =>  demo.ColorText          := false

switch (idzx) // Main Calls via => On Next Bar Call
    8   =>  demo.resize(10)
    16  =>  demo.resize(7)
    21  =>  demo.TextColor          :=color.blue
    25  =>  demo.TextColorBG        := color.orange
    29  =>  demo.resetTextColorBG()
    33  =>  demo.resetTextColor()
    37  =>  demo.StatusColor        :=color.green
    41  =>  demo.StatusColorBG      :=color.white
    45  =>  demo.resetStatusColorBG()
    49  =>  demo.resetStatusColor()
    53  =>  demo.FrameColor         :=color.green
    57  =>  demo.resetFrameColor()
    61  =>  demo.setColors(customFG)
    62  =>  demo.ColorText          := true
    73  =>  demo.setColorsHC(customHC)
    74  =>  demo.HighlightText      := true
    85  =>  demo.resetColors()
    86  =>  demo.ColorText          := true
    95  =>  demo.resetColorsHC()
    96  =>  demo.HighlightText      := true

    114 =>  demo.setLevelName(40,'Custom Code 40')
    116 =>  demo.setColor(36,color.red)
    118 =>  demo.setColorHC(40,color.black), demo.setColor(40,color.orange)
    121 =>  demo.setColorBG(41,color.yellow)

    126 =>  demo.StatusBarAtBottom  := false
    131 =>  demo.HeaderAtTop        := false
    136 =>  demo.ShowHeader         := false
    142 =>  demo.MoveLogUp          := false
    154 =>  demo.ShowHeader         := true, demo.setFontHeader(font.family_monospace)
    156 =>  demo.ShowBarIndex       := true
    160 =>  demo.ShowDateTime       := true
    162 =>  demo.dateTimeFormat('dd.MMM.yy')
    164 =>  demo.dateTimeFormat('')
    167 =>  demo.PageOnEveryBar     := true, demo.setFontHeader()
    170 =>  demo.PageHistory        := 1
    186 =>  demo.ShowQ2:=false, demo.ShowQ6:=false
    189 =>  demo.ShowQ2:=true, demo.ShowQ6:=true
    190 =>  demo.ShowQ3:=false, demo.ShowQ5:=false
    199 =>  demo.AutoMerge          := true
    203 =>  demo.TabSizeQ1:=1, demo.TabSizeQ2:=2, demo.TabSizeQ3:=3
    217 =>  demo.Status:="Look we have a status message now, that will persist across updates", demo.setFontStatus(font.family_monospace), demo.setFontMetaStatus(font.family_monospace)
    223 =>  demo.ShowMetaStatus     := false, demo.setFontStatus(),demo.setFontMetaStatus()
    226 =>  demo.ShowStatusBar      := false
    231 =>  demo.MarkNewBar         := true
    238 =>  demo.MinWidth           := 200
    244 =>  demo.ShowLogLevels      := true
    245 =>  demo.RestrictLevelsToKey7     :=true
    247 =>  demo.ReplaceWithCodes:=true
    249 =>  demo.ShowLogLevels      := false
    256 =>  demo.IsConsole          := true
    262 =>  demo.IsConsole          := false
    272 =>  demo.turnPage()
    305 =>  demo.ShowMinimumLevel   := 3
    306 =>  demo.ShowMinimumLevel   := 4
    312 =>  demo.undo()
    313 =>  demo.undo(3)
    314 =>  demo.undo(16)
    322 =>  demo.undo2()
    323 =>  demo.undo1(2)
    324 =>  demo.undo2(20)

if (idzx>=1 and idzx<167 ) or (idzx>172  and idzx<178 ) or (idzx>180  and idzx<231 ) or (idzx>233 and idzx<255 ) or (idzx>261 and idzx<279 ) or (idzx>299  and idzx<304) or (idzx>304 and idzx<312 and idzx!=311) or (idzx>314 and idzx<321) or (idzx>324 and idzx<=xbarFinalTestDone and (idzx!=244  or idzx!=247))
    gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
    zx+=1
if idzx==167
    for x=1 to 6
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
        zx+=1
if (idzx>=168  and idzx<=172 )
    for x=1 to 5
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
        zx+=1    
if (idzx>=178  and idzx<=180 )
    for x=1 to 6
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.page(ezx,gm1,gm2,gm3,gm4,gm5,gm6,    page=gm1!=o_skiplog) 
        zx+=1    
if (idzx>=231  and idzx<=233 )
    for x=1 to 4
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
        zx+=1    
if (idzx==244  or idzx==247 )
    for x=1 to 9
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx+x,gm1,gm2,gm3,gm4,gm5,gm6,font=font.family_monospace,    log=gm1!=o_skiplog) 
        zx+=1    
if (idzx>=255 and idzx<=261)
    gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx,m1=gm1+gm2+gm3+gm4+gm5+gm6,    log=gm1!=o_skiplog) 
    zx+=1    
if idzx==279
    for x=1 to 5
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log1(ezx,gm1,cq=2,    log=gm1!=o_skiplog) 
        zx+=1
if (idzx>=280 and idzx<=286) or (idzx>=291 and idzx<=299)
    gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log2(ezx,gm2,cq=3,    log=gm2!=o_skiplog)
    zx+=1
if (idzx>=287 and idzx<=290) 
    gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log3(ezx,gm3,cq=4,    log=gm3!=o_skiplog) 
    zx+=1
if idzx==304
    for x=0 to 7
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx+x,ezx+x+10,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
        zx+=1
if idzx==311
    for x=1 to 15
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log(ezx+x,ezx+x,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
        zx+=1
if idzx==321
    for x=1 to 5
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log1(ezx,gm1,cq=4,    log=gm1!=o_skiplog)
        zx+=1
    for x=1 to 7
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log2(ezx,gm2,cq=5,    log=gm2!=o_skiplog)
        zx+=1
    for x=1 to 4
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log3(ezx,gm3,cq=6,    log=gm3!=o_skiplog)
        zx+=1
    for x=1 to 3
        gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), gs:=logxBus.get(zx,prodcolstatusL), demo.log2(ezx,gm2,cq=7,    log=gm2!=o_skiplog)
        zx+=1

if (idzx>=1 and idzx<167 )
    demo.Status:=logxBus.get(zx-1,prodcolstatusL)
else if not(idzx>=217  and idzx<=219 ) and (idzx>=1 and idzx<=xbarFinalTestDone)
    demo.Status:=logxBus.get(zx-1,prodcolstatusL)
//______ xx ______________________________ TESTING Logx


//______ == ______________________________ TESTING Console

if idzc==1 or barstate.isfirst
    zc:=1
    demo.IsConsole:=true
    demo.clear()
    demo.resize(maxLog)
    demo.resetFrameColor()
    demo.PageOnEveryBar  := false
    demo.MoveLogUp       := true
    demo.ColorText       := false
    demo.HighlightText   := false
    demo.ShowBarIndex    := false
    demo.ShowDateTime    := false
    demo.ShowLogLevels   :=false
    demo.ReplaceWithCodes:=false
    demo.ShowHeader      := true
    demo.HeaderAtTop     := true
    demo.StatusBarAtBottom := true
    demo.ShowStatusBar   := true
    demo.ShowMetaStatus  := true
    demo.ShowQ1:=true, demo.ShowQ2:=true, demo.ShowQ3:=true, demo.ShowQ4:=true, demo.ShowQ5:=true, demo.ShowQ6:=true
    demo.TabSizeQ1:=0, demo.TabSizeQ2:=0, demo.TabSizeQ3:=0, demo.TabSizeQ4:=0, demo.TabSizeQ5:=0, demo.TabSizeQ6:=0
    demo.HeaderQ1:='s.q1', demo.HeaderQ2:='s.q2', demo.HeaderQ3:='s.q3', demo.HeaderQ4:='s.q4', demo.HeaderQ5:='s.q5', demo.HeaderQ6:='s.q6' 
    demo.AutoMerge       := true
    demo.dateTimeFormat('dd.MMM.yy HH:mm')
    demo.FrameColor      :=color.blue
    demo.MarkNewBar      := false
    demo.MinWidth        := 80
    demo.PageHistory     := 0
    demo.RestrictLevelsToKey7  := false
    demo.StatusTooltip   :='Console Testing'
    demo.ShowMinimumLevel:= 0

czc+=1
if idzc==1 or idzc==61 or idzc==73 or idzc==85 or idzc==96 or idzc==189 or idzc==307 or idzc==310
    czc:=0
if idzc==308
    czc:=8
ezc=((czc-1)%__colors)+1

switch(idzc)  //Prep resize and clear
    66  =>  demo.resize(12)
    147 =>  demo.resize(5), demo.clear()
    159 =>  demo.clear()
    171 =>  demo.resize(6)
    175 =>  demo.resize(15)
    200 =>  demo.clear(), demo.resize(26), demo.FrameColor:=color.blue
    233 =>  demo.resize(30)
    243 =>  demo.resize(8)
    295 =>  demo.clear(), demo.resize(24), demo.FrameColor:=color.blue
    305 =>  demo.clear()
    311 =>  demo.resize(18)
    
switch(idzc)  //PreCalls #1
    18  =>  demo.resetFrameColor()
    70  =>  demo.ColorText          := false
    82  =>  demo.HighlightText      := false
    93  =>  demo.ColorText          := false
    104 =>  demo.HighlightText := false,  demo.ShowLogLevels:=false
    128 =>  demo.StatusBarAtBottom  := true
    143 =>  demo.ShowMetaStatus     := true
    147 =>  demo.StatusBarAtBottom  := false
    159 =>  demo.MoveLogUp          := true
    169 =>  demo.ShowDateTime       := false
    170 =>  demo.FrameColor         := color.blue
    178 =>  demo.PageOnEveryBar     := false, demo.resetFrameColor()
    190 =>  demo.PageHistory        := 0
    198 =>  demo.TabSizeQ1:=0
    230 =>  demo.resetFrameColor()
    236 =>  demo.MarkNewBar         := false
    242 =>  demo.MinWidth           := 80
    310 =>  demo.ShowMinimumLevel   := 0

switch(idzc)  //Prep Calls #2
    143 =>  demo.ShowStatusBar      := true
    159 =>  demo.StatusBarAtBottom  := true
    170 =>  demo.ShowBarIndex       := false
    198 =>  demo.PrefixLogLevel     := false

switch (idzc) // Main Calls via => On Next Bar Call
    8   =>  demo.resize(10)
    16  =>  demo.resize(7)
    21  =>  demo.TextColor          :=color.blue
    25  =>  demo.TextColorBG        := color.orange
    29  =>  demo.resetTextColorBG()
    33  =>  demo.resetTextColor()
    37  =>  demo.StatusColor        :=color.green
    41  =>  demo.StatusColorBG      :=color.white
    45  =>  demo.resetStatusColorBG()
    49  =>  demo.resetStatusColor()
    53  =>  demo.FrameColor         :=color.blue
    57  =>  demo.resetFrameColor()
    61  =>  demo.setColors(customFG)
    62  =>  demo.ColorText          := true
    73  =>  demo.setColorsHC(customHC)
    74  =>  demo.HighlightText      := true
    85  =>  demo.resetColors()
    86  =>  demo.ColorText:= true, demo.ShowLogLevels:=true
    95  =>  demo.resetColorsHC()
    96  =>  demo.HighlightText      := true
    114 =>  demo.setLevelName(40,'Custom Code 40')
    116 =>  demo.setColor(36,color.red)
    118 =>  demo.setColorHC(40,color.black), demo.setColor(40,color.orange)
    121 =>  demo.setColorBG(41,color.yellow)
    126 =>  demo.StatusBarAtBottom  := false
    133 =>  demo.Status:="Look we have a status message now, that will persist across updates", demo.setFontStatus(font.family_monospace)
    136 =>  demo.Status:=""
    139 =>  demo.ShowMetaStatus     := false, demo.setFontStatus()
    142 =>  demo.ShowStatusBar      :=false
    147 =>  demo.MoveLogUp          := false
    161 =>  demo.ShowBarIndex       := true
    165 =>  demo.ShowDateTime       := true
    167 =>  demo.dateTimeFormat('dd.MMM.yy')
    169 =>  demo.dateTimeFormat('')
    172 =>  demo.PageOnEveryBar     := true
    175 =>  demo.PageHistory        := 1
    190 =>  demo.PrefixLogLevel     := true
    191 =>  demo.TabSizeQ1:=1
    233 =>  demo.MarkNewBar         := true
    240 =>  demo.MinWidth           := 200
    246 =>  demo.IsConsole          := false
    255 =>  demo.IsConsole          := true
    265 =>  demo.turnPage()
    308 =>  demo.ShowMinimumLevel   := 3
    309 =>  demo.ShowMinimumLevel   := 4
    315 =>  demo.undo()
    316 =>  demo.undo(3)
    317 =>  demo.undo(16)

if (idzc>=1 and idzc<172 ) or (idzc>177  and idzc<183 ) or (idzc>185  and idzc<233 ) or (idzc>235  and idzc<250 ) or (idzc>252  and idzc<272) or (idzc>289  and idzc<295) or (idzc>302  and idzc<=306) or (idzc>=308 and idzc<314) or (idzc>317 and idzc<=cbarFinalTestDone)
    gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
    zc+=1
if idzc==172 
    for x=1 to 6
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
        zc+=1
if (idzc>=173 and idzc<=177) 
    for x=1 to 5
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
        zc+=1    
if (idzc>=183 and idzc<=185)
    for x=1 to 6
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.page(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    page=gm1!=o_skiplog)
        zc+=1    
if (idzc>=233 and idzc<=235)
    for x=1 to 4
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
        zc+=1
if (idzc>=250 and idzc<=252)
    gm1:=consoleBus.get(zc,prodcolm1), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
    zc+=1
if idzc==272
    for x=1 to 5
        gm1:=consoleBus.get(zc,prodcolm1), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm1,1,    log=gm1!=o_skiplog) 
        zc+=1
if (idzc>=273 and idzc<=279) or (idzc>=284 and idzc<=289)
    gm1:=consoleBus.get(zc,prodcolm1), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm2,2,    log=gm2!=o_skiplog) 
    zc+=1
if (idzc>=280 and idzc<=283) 
    gm1:=consoleBus.get(zc,prodcolm1), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm3,3,    log=gm3!=o_skiplog) 
    zc+=1
if idzc==295
    for x=1 to 23
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm2,2,    log=gm2!=o_skiplog)
        zc+=1
if idzc==296
    gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm2,2,    log=gm2!=o_skiplog)
    zc+=1
if (idzc>=297 and idzc<=302)
    gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.alog(ezc,gm1,1,    log=gm1!=o_skiplog)
    zc+=1
if idzc==307
    for x=0 to 7
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc+x,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog)
        zc+=1
if idzc==314
    for x=1 to 15
        gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), gs:=consoleBus.get(zc,prodcolstatusC), demo.log(ezc+x,ezc+x,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog) 
        zc+=1


if (idzc>=1 and idzc<123) and (idzc>135 and idzc<167)
    demo.Status:=consoleBus.get(zc-1,prodcolstatusC)
else if not(idzc>=133 and idzc<=135) and (idzc>=1 and idzc<=cbarFinalTestDone)
    demo.Status:=consoleBus.get(zc-1,prodcolstatusC)

//______ xx ______________________________ TESTING Console


//______ == ______________________________ TESTING Attachment of Console to Logx
var console = logger.log.new()
console.init(maxLog,true)

if idza==-6
    demo.resize(15)

if idza==1 or barstate.isfirst
    za:=1
    console.IsConsole:=true
    console.clear()
    console.resize(5)
    console.FrameColor      := color.maroon
    console.PageOnEveryBar  := false
    console.MoveLogUp       := true
    console.ColorText       := false
    console.HighlightText   := false
    console.ShowBarIndex    := false
    console.ShowDateTime    := false
    console.ShowLogLevels   :=false
    console.ReplaceWithCodes:=false
    console.ShowHeader      := true
    console.HeaderAtTop     := true
    console.StatusBarAtBottom := true
    console.ShowStatusBar   := true
    console.ShowMetaStatus  := true
    console.ShowQ1:=true, console.ShowQ2:=true, console.ShowQ3:=true, console.ShowQ4:=true, console.ShowQ5:=true, console.ShowQ6:=true
    console.TabSizeQ1:=0, console.TabSizeQ2:=0, console.TabSizeQ3:=0, console.TabSizeQ4:=0, console.TabSizeQ5:=0, console.TabSizeQ6:=0
    console.HeaderQ1:='s.q1', console.HeaderQ2:='s.q2', console.HeaderQ3:='s.q3', console.HeaderQ4:='s.q4', console.HeaderQ5:='s.q5', console.HeaderQ6:='s.q6' 
    console.AutoMerge       := true
    console.dateTimeFormat('dd.MMM.yy HH:mm')
    console.FrameColor      :=color.blue
    console.MarkNewBar      := false
    console.MinWidth        := 80
    // dataLogx.ShowQ1:=true, dataLogx.ShowQ2:=false, dataLogx.ShowQ3:=false, dataLogx.ShowQ4:=false, dataLogx.ShowQ5:=false, dataLogx.ShowQ6:=false

    demo.Status:=''
    demo.IsConsole:=false
    demo.clear()
    demo.PageOnEveryBar  := false
    demo.MoveLogUp       := true
    demo.ColorText       := false
    demo.HighlightText   := false
    demo.ShowBarIndex    := false
    demo.ShowDateTime    := false
    demo.ShowLogLevels   :=false
    demo.ReplaceWithCodes:=false
    demo.ShowHeader      := true
    demo.HeaderAtTop     := true
    demo.StatusBarAtBottom := true
    demo.ShowStatusBar   := true
    demo.ShowMetaStatus  := true
    demo.ShowQ1:=true, demo.ShowQ2:=true, demo.ShowQ3:=true, demo.ShowQ4:=true, demo.ShowQ5:=true, demo.ShowQ6:=true
    demo.TabSizeQ1:=0, demo.TabSizeQ2:=0, demo.TabSizeQ3:=0, demo.TabSizeQ4:=0, demo.TabSizeQ5:=0, demo.TabSizeQ6:=0
    demo.HeaderQ1:='s.q1', demo.HeaderQ2:='s.q2', demo.HeaderQ3:='s.q3', demo.HeaderQ4:='s.q4', demo.HeaderQ5:='s.q5', demo.HeaderQ6:='s.q6' 
    demo.AutoMerge       := true
    demo.dateTimeFormat('dd.MMM.yy HH:mm')
    demo.FrameColor      :=color.yellow
    demo.MarkNewBar      := false
    demo.MinWidth        := 80

    demo.StatusTooltip   :='Attachment Testing'
    console.StatusTooltip   :='Attachment Testing'


cza+=1
if idza==1 or idza==60 or idza==73 or idza==85 or idza==96 or idza==170
    cza:=0
eza=((cza-1)%__colors)+1

px_gold = str.tostring(request.security('TVC:GOLD',timeframe.period,close))+' = Gold'
px_ukoil= str.tostring(request.security('TVC:UKOIL',timeframe.period,close))+' = Brent Crude'
px_dow  = str.tostring(request.security('TVC:DJI',timeframe.period,close))+' = Dow'
px_ftse = str.tostring(request.security('TVC:UKX',timeframe.period,close))+' = FTSE'

if idza==6
    console.clear()

if (idza>=1 and idza<7) or (idza>10 and idza<=abarFinalTestDone)
    gm1:=consoleBus.get(zc,prodcolmsg), gm2:=consoleBus.get(zc,prodcolm2), gm3:=consoleBus.get(zc,prodcolm3), gm4:=consoleBus.get(zc,prodcolm4), gm5:=consoleBus.get(zc,prodcolm5), gm6:=consoleBus.get(zc,prodcolm6), 
    gs:=consoleBus.get(zc,prodcolstatusC)
    console.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog), console.Status:=gs

    gm1:=logxBus.get(zx,prodcolm1), gm2:=logxBus.get(zx,prodcolm2), gm3:=logxBus.get(zx,prodcolm3), gm4:=logxBus.get(zx,prodcolm4), gm5:=logxBus.get(zx,prodcolm5), gm6:=logxBus.get(zx,prodcolm6), 
    gs:=logxBus.get(zx,prodcolstatusL)
    demo.log(ezc,gm1,gm2,gm3,gm4,gm5,gm6,    log=gm1!=o_skiplog), demo.Status:=gs

if (idza>=1 and idza<=abarFinalTestDone)
    za+=1
    zx+=1
    zc+=1

switch idza
    6   =>  demo.attach(console,'bottom'), demo.SeparatorColor:=c_cream
    7   =>  console.page(0,'Inside attached console one can track, for instance, other markets?\n'+px_gold+'\n'+px_ukoil+'\n'+px_dow+'\n'+px_ftse), demo.log(eza,'1 of 4 .. Inside Logx tracking current ticker = '+syminfo.ticker,'Current price = <'+str.tostring(close)+'>')
    8   =>  console.page(0,'Inside attached console one can track, for instance, other markets?\n'+px_ukoil+'\n'+px_dow+'\n'+px_ftse+'\n'+px_gold), demo.log(eza,'2 of 4 .. Inside Logx tracking current ticker = '+syminfo.ticker,'Current price = <'+str.tostring(close)+'>')
    9   =>  console.page(0,'Inside attached console one can track, for instance, other markets?\n'+px_dow+'\n'+px_ftse+'\n'+px_gold+'\n'+px_ukoil), demo.log(eza,'3 of 4 .. Inside Logx tracking current ticker = '+syminfo.ticker,'Current price = <'+str.tostring(close)+'>')
    10  =>  console.page(0,'Inside attached console one can track, for instance, other markets?\n'+px_ftse+'\n'+px_gold+'\n'+px_ukoil+'\n'+px_dow), demo.log(eza,'4 of 4 .. Inside Logx tracking current ticker = '+syminfo.ticker,'Current price = <'+str.tostring(close)+'>')
    13  =>  demo.attach(console,'Left')
    15  =>  console.StatusBarAtBottom:=false
    16  =>  demo.attach(console,'Top')
    19  =>  demo.attach(console,'Right')
    22  =>  demo.StatusBarAtBottom:=false
    23  =>  demo.attach(console,'anywhere')
    26  =>  demo.detach(console)
    28  =>  demo.StatusBarAtBottom:=true, console.StatusBarAtBottom:=true

console.show  (position= L_bottom_center.getTablePosition(),hhalign=hhalign_uat, hvalign=hvalign_uat, hsize=hsize_uat, thalign=thalign_uat, tvalign=tvalign_uat, tsize=tsize_uat, show=showAttachedConsole)
//______ xx ______________________________ TESTING Attachment of Console to Logx

demo.show  (position= pos_uat,hhalign=hhalign_uat, hvalign=hvalign_uat, hsize=hsize_uat, thalign=thalign_uat, tvalign=tvalign_uat, tsize=tsize_uat, show=(showLogx or showConsole or showAttachedConsole or consoleAttached), attach=consoleAttached?console:na)
demo.showColors(position=position.bottom_left,showColors=(idzx>=108 and idzx<=123) or (idzc>=108 and idzc<=123))

// logger.3    td4.3   td5.3

