IMPORTANT ANNOUNCEMENT

These forums were permanently set to read-only mode on July 20, 2022. From that day onwards, no new posting or comment is allowed on the site, but the historical content remains intact and searchable.

A new location for posting questions about PlanetPress Suite is now available:

OL Learn - PlanetPress Classic (opens in new tab)

Topic Options
#50878 - 02/17/15 11:59 AM Selecting middle of string
Woodbine Offline
OL Newbie

Registered: 02/17/15
Posts: 1
Hi,

I've searched this forum looking for similar code to mine and trying to amend what I have found to suit me, but for a novice code writer I'm struggling to achieve what I need. But I apologise if this is a bit basic.

I'm trying to select the first name of a full name.

So I need the Dolph in 'Mr Dolph Lundgren'.

At the moment all I've achieved is removing the 'Mr' blush
--------------

define(&datastr, string, '')
define(&i, integer, 1)
define(&curstr, string, '')

&datastr := @(3,1,30)

repeat
&i := &i + 1
until((mid(&datastr, &i, 1) = ' ') or (&i >= 30))

&i := &i + 1

&curstr := mid(&datastr, &i, 30)

show(trim(&curstr))

&GlobalVariable9 := &curstr

--------------
In the long run, I'm going to need an if statement where if the first name is just an initial, use the entire string, but god help me, my head would explode if I tried that at the moment.

Any help would be greatly appreciated. Except the kind that directs me towards the tutorial.....

Top
#50882 - 02/17/15 04:03 PM Re: Selecting middle of string [Re: Woodbine]
Riad Kerbache
Unregistered


Greeting,

Here is a way you can set your planet press talk code. &FirstName is define as a string in Global Variables

define(&datastr, string , '')

define(&i, integer, 0)

&datastr := @(1,1,30)

search(&datastr,' ') %Start loop

if(&i=1)
&FirstName:= &datastr
endif()
&i := &i + 1

endsearch()

Hope this will help you.

Top