Source language: Translate to:

Strings about

General questions about NeoBook

Moderator: Neosoft Support

Strings about

Postby Palamar » Thu Jan 08, 2015 1:52 pm

Hello People ;

This week I have been programming in Neobook and I realized mismanagement of strings which possesses. Actually there are things that are impossible to do. I know there are many plugins that enhance this aspect but have not found one that, for example , to obtain a string between two others .

Assuming we have this string :

"Hi , I'm a programmer Neobook "

I have found no action taken by the string that goes from "I " to " Neobook " . In which the resultant is " 'm programmer " .

They could be addressed these issues through scripts JavaScript eg ?, will improve in the future Neobook in this section ? ...

Greetings !
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Strings about

Postby Gaev » Thu Jan 08, 2015 2:36 pm

Palamar:

Assuming we have this string :
"Hi , I'm a programmer Neobook "
I have found no action taken by the string that goes from "I " to " Neobook " . In which the resultant is " 'm programmer " .

I don't think you meant to have a space after the I ... so I am assuming you meant ...

Assuming we have this string :
"Hi , I'm a programmer Neobook "
I have found no action taken by the string that goes from "I" to " Neobook " . In which the resultant is " 'm programmer " .


Here is some code that can handle it ...
Code: Select all
SetVar "[SourceString]" "Hi , I'm a programmer Neobook "
SetVar "[PrefixString]" "I"
SetVar "[SuffixString]" " Neobook "

GoSub "DoTheExtract"
AlertBox "ExtractedString" "[ExtractedString]"

... and the subroutine would look like ...
Code: Select all
:DoTheExtract
... the prefix part
StrLen "[SourceString]" "[SourceStringSize]"
SearchStr "[PrefixString]" "[SourceString]" "[PrefixLocation]" "[CaseSensitive]"
If "[PrefixLocation]" ">" "0"
   ... extract rest of String
   SubStr "[SourceString]" "[PrefixLocation]+1" "[SourceStringSize]-[PrefixLocation]" "[RestOfString]"
Else
   SetVar "[ExtractedString]" ""
   Return
Endif

... now for the suffix part
StrLen "[RestOfString]" "[RestOfStringSize]"
SearchStr "[SuffixString]" "[RestOfString]" "[SuffixLocation]" "[CaseSensitive]"
If "[SuffixLocation]" ">" "0"
   ... extract everything before match
   SubStr "[RestOfString]" "1" "[SuffixLocation]-1" "[ExtractedString]"
Else
   SetVar "[ExtractedString]" ""
Endif
Return


If you want to have even less (calling) code, you could turn the Subroutine into a function that can be Call'ed like so ...
Code: Select all
Call "DoTheExtractThing" "[anySourceString]" "[anyPrefixString]"  "[anySuffixString]" "[anyExtractedString]"
or
Call "DoTheExtractThing" "Hi , I'm a programmer Neobook " "I"  " Neobook " "[myExtractedString]"
User avatar
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: Strings about

Postby Palamar » Thu Jan 08, 2015 8:34 pm

Gaev , thanks for your answer , take some time to Neo , my solution had happened as you mention , but here is reflected as a simple situation like extracting a string ends up being a mess in Neobook , that should ( at this point ) can be done with a single action. From already thank you for the reply.
Palamar
 
Posts: 157
Joined: Wed Apr 06, 2005 4:34 pm

Re: Strings about

Postby mishem » Thu Jan 08, 2015 11:42 pm

For working with strings is a wonderful plugin hpwControl
mishem
 
Posts: 575
Joined: Mon Oct 08, 2012 1:51 pm


Return to General NeoBook Discussions

Who is online

Users browsing this forum: Bing [Bot] and 1 guest

cron