Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
azimabadi
Creator III
Creator III

Return value of RemoveExpression

Hi all,

i need to delete all Expressions of a chart in module. In API Guide, is documented that RemoveExpression returns the number of remaining Expressions in chart. I Use something like this:

SET chart = ActiveDocument.GetSheetObject("CH01")

n =  chart.RemoveExpression 0

But this dosn't work. When i write the second line like bellow:

chart.RemoveExpression 0

modul runs without problem. But the number of remaining Expressions is very important for me.

I will appreciate every idea.

Regards

Peyman

2 Replies
chematos
Specialist II
Specialist II

I can´t assign the returns to a variable.

If you want remove all expressions you must use chart.RemoveExpression all but I think you already know that.

set chart = ActiveDocument.GetSheetObject("CH01")

set cp = chart.GetProperties

x = cp.Expressions.Item(0).Count

You could count the number of expressions of each chart before remove all of them and use the sentence to remove all:

chart.RemoveExpression all

hope this helps,

Chema


azimabadi
Creator III
Creator III
Author

Thank you Chema,

but "cp.Expressions.Item(0).Count" returns the number of subexpressions of first expression and "RemoveExpression all" is like "RemoveExpression 0". I think "all" is interprated as a variable with "0" value.

i tryed many ways and finally found out that the code belows has the correct result:

SET chart = ActiveDocument.GetSheetObject("CH01")

SET cp    = chart.Getproperties

exprCount = cp.Expressions.Count

FOR i = 1 TO exprCount

     chart.RemoveExpression 0

NEXT