Cancel
Showing results for 
Search instead for 
Did you mean: 

format created method

Hello

 

I have one question about create methods by another methods.

 

I am trying to create method by drag and drop .

 

I am using this method

 

(draggedObjects: object[])
is
obj : object;
do
-- @,?: drop target

for local i := 1 to draggedObjects.dim loop
obj := draggedObjects[i];
-- enter your source code here

obj.program:=
"is "+
"do "+
"if @.istractor=true then"+
"@.speed:=@.rychlost_zakruta;"+
"end;"+
"end; "

next;

end;

 

Problem is that created method is written in one row it doesnt format as i want.

Created method:is do if @.istractor=true then@.speed:=@.rychlost_zakruta;end;end; 

 

How can I format created method?

I split method in several rows.

I didnt  find any operator that will move code in another row 

 

I am sending also model in 11,3.


Thanks for helping me

 

S.Dilsky

 

6 REPLIES

Re: format created method

Valued Contributor
Valued Contributor

Hello,

you can use ascii characters when you want to write on a new line and/or tab:

 

chr(ascii_code)
  • new line: chr(10)
  • tab: chr(9)

So it is:

obj.program:=
"is "+chr(10)+
"do "+chr(10)+
chr(9)+"if @.istractor=true then"+chr(10)+
chr(9)+chr(9)+"@.speed:=@.rychlost_zakruta;"+chr(10)+
chr(9)+"end;"+chr(10)+
"end; "

Regards,

 

BD

99 little bugs in the code,
99 little bugs in the code.
Take one down, patch it around.
127 little bugs in the code...

Re: format created method

Siemens Phenom Siemens Phenom
Siemens Phenom

There is also another way to achieve this, using a backslash at the line end inside a string:

    obj.program := "is\
do\
    if @.istractor then\
        @.speed:=@.rychlost_zakruta;\
    end;\
end;";
_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: format created method

Thanks for tip 

So easy but hard to find

Re: format created method

Thanks but when i try it there is error :
End of line in string constant

Re: format created method

Siemens Phenom Siemens Phenom
Siemens Phenom

I don't get an error.

Very strange.

Please load my model and run 'Method'.

 

_________________________________________________________________
Did you like the answer? Then click the Thumbs Up button.
Did the answer solve your problem? Then accept the answer as solution.

Re: format created method

I have opened model and you have patched version.

I have verision 11.3.0 you have 11.3.4

I think this was the problem 

Thank you for hleping me