[futurebasic] Re: [FB] String >255 chr

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 2009 : Group Archive : Group : All Groups

From: Robert Purves <listrp@...>
Date: Wed, 25 Mar 2009 20:00:39 +1300

Piet en Claudine wrote:

> In my search to modernisation to FB5, I’ would like to make a  
> popmenu with a lot of items in it.
>
> local fn BouwPopMenu( id as long )
> dim as MenuRef  mRef
> menu id, 0, _enable, ""
> menu id, 1, _enable, popstring
> mRef = fn GetMenuHandle( id )
> DeleteMenu( id )
> InsertMenu( mRef, -1 )
> end fn
>
> popstring = "Actief;Niet actief"
> fn BouwPopMenu( 2000 )
> SetRect( rechthoek, 250, 80, 460, 95):appearance button  
> 2000,,,2000,-1,"State   ",rechthoek,_kControlPopupButtonProc

> But now, if popstring reaches 255 characters it’s finisched

This allows two Str255 values for populating the menu.

'-----------------------
local mode
local fn BouwPopMenu( id as long, firstItems as Str255, lastItems as  
Str255 )
dim as MenuRef  mRef
dim as long i, useLastItems

useLastItems = 1
i = -1
do
i = instr( i + 1, firstItems , ";" )
useLastItems++
until ( i == 0  )
menu id, 0, _enable, ""
menu id, 1, _enable, firstItems
menu id, useLastItems, _enable, lastItems
mRef = fn GetMenuHandle( id )
DeleteMenu( id )
InsertMenu( mRef, -1 )
end fn

window 1
dim as Str255 popstring1, popstring2
dim as Rect   rechthoek

popstring1 = "Actief;Niet actief;Foo"
popstring2 = "Bar;More Stuff;Yet Again;Yet More Again"
fn BouwPopMenu( 2000, popstring1, popstring2 )
SetRect( @rechthoek, 250, 80, 460, 95)
appearance button 2000,,, 2000, -1, "State: ", rechthoek,  
_kControlPopupButtonProc
do
HandleEvents
until gFBQuit
'-----------------------

Robert P.