fbpx

fixed XIDE plugin - or different behavior of .NET methods

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
1 year 5 months ago #1 by Wolfgang Riedmann
Hi,

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

I had replaced:
Project:BaseOutputFolder + Config:cSubFolder
by
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
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.
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

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #2 by Chris Pyrgas
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Wolfgang Riedmann
  • Wolfgang Riedmann's Avatar Topic Author
  • Offline
More
1 year 5 months ago #3 by Wolfgang Riedmann
Replied by Wolfgang Riedmann on topic fixed XIDE plugin - or different behavior of .NET methods
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

Please Log in or Create an account to join the conversation.

More
1 year 5 months ago #4 by Chris Pyrgas
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

XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.