xsharp.eu • fixed XIDE plugin - or different behavior of .NET methods
Page 1 of 1

fixed XIDE plugin - or different behavior of .NET methods

Posted: Tue Jul 25, 2017 7:12 am
by wriedmann
Hi,

I had to fix my XIDE plugin as in the last version the "Open BIN folder" don't worked anymore.

I had replaced:

Code: Select all

Project:BaseOutputFolder + Config:cSubFolder
by

Code: Select all

Path.Combine( Project:BaseOutputFolder, Config:cSubFolder )
and since cSubFolder had a leading "" the Path.Combine method returned the cSubFolder alone.

Therefore I added now the following static function

Code: Select all

static method CombinePath( cPath1 as string, cPath2 as string ) as string
local cReturn as string
	
if cPath2:Length > 0 .and. cPath2[0] == Path.DirectorySeparatorChar
    cReturn := Path.Combine( cPath1, cPath2:Substring( 1 ) )
else
    cReturn := Path.Combine( cPath1, cPath2 )
endif
	
return cReturn
The updated plugin with sources is here: www.riedmann.it/download/XIDE_WR_Plugin.zip

Wolfgang

P.S. I had to write also my own SubStr() extension method because I would not check the length every time.

Code: Select all

static method SubStr( self cString as string, nStart as int, nLen as int ) as string
// 0-based!!!
local nStringLen as int
local cReturn as string
	
nStringLen := cString:Length	
if nStart < 0
  if ( nStart * -1 ) >= nStringLen
    nStart := 0
  else
    nStart := nStringLen + nStart
  endif
endif
if nLen >= ( nStart + nStringLen )
  cReturn := cString
else
  cReturn := cString:Substring( nStart, nLen )
endif
	
return cReturn

fixed XIDE plugin - or different behavior of .NET methods

Posted: Tue Jul 25, 2017 3:23 pm
by Chris
Hi Wolfgang,

Thanks you! Especially the command "Open BIN folder" I am using it many times every day! Also the "Administrator command prompt in BIN folder" is very handy at times and I am glad that you have done this in your plugin, so I did not have to research myself how to implement this in XIDE itself :-)

Chris

fixed XIDE plugin - or different behavior of .NET methods

Posted: Tue Jul 25, 2017 3:29 pm
by wriedmann
Hi Chris,

I'm happy if my plugin serves you well! So at least I can contribute a bit also.

Initially, I tried to use the pure .NET methods whenever possible because I was thinking they are perfect, but slowly I'm discovering that some of them don't work as I would expect. So I'm more and more replacing the string.Substring() method by my own string.Substr() method that is more robust - I don't like to check the string length every time I need to call string.SubString() and to risk an exception otherwise.

Wolfgang

fixed XIDE plugin - or different behavior of .NET methods

Posted: Tue Jul 25, 2017 3:46 pm
by Chris
Hi Wolfgang,

Absolutely agreed, the system string methods are designed for maximum performance and are less "forgiving" that the runtime functions of VO. So I also often use my own function wrappers, or call the already defined SubStr(), Left() etc runtime functions, which are also fast enough (the strongly typed versions).

Chris