[futurebasic] Re: [FB] [X-FB] RealBasic, etc. is now...

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : June 2013 : Group Archive : Group : All Groups

From: Bernie <fblist.bw@...>
Date: Fri, 21 Jun 2013 15:23:23 +0100
Steve wrote:

> The syntax is much more familiar than Objective C.
> 
> I haven't spent a lot of time with Xojo but it looks more promising than RB did and there is a lot of code that can easily be used from existing FB projects unrelated to the UI.
> 
> My next step is to create or find the code that reads XML files like the code below. I don't know how much of these are easily translated to Xojo
> 
> 
> url = fn CFURLCreateFromFSRef( 0, #sRef )
> 
> Long if ( url )
> Long if ( fn CFURLCreateDataAndPropertiesFromResource( 0, url, @dataRef, #0, 0, #0 ) )
> 
> Long if ( dataRef )
> array = fn CFPropertyListCreateFromXMLData( 0, dataRef, 0, #0 )
> 

Haven't tested the above functions, but maybe this would be start. Looks like Carbon functions must first be declared as we do toolboxes in FB. Perhaps the full headers are available somewhere (?)

Created a default desktop project, added a TextArea (scrolling text view) plus a button and dragged an image file into the project's contents. Here's the button action.
'---------------
  declare function CFBundleGetMainBundle lib "Carbon.framework" () as ptr
  declare function CFBundleCopyResourceURL lib "Carbon.framework" ( bundle as ptr, filename as CFStringRef, resourceType as CFStringRef, subDirName as CFStringRef ) as ptr
  declare function CFURLGetString lib "Carbon.framework" ( url as ptr ) as CFStringRef
  declare sub CFRelease lib "Carbon.framework" ( cf as ptr )
  
  dim url as ptr
  
  url = CFBundleCopyResourceURL( CFBundleGetMainBundle(), "UNO.jpg", nil, nil )
  if ( url <> nil ) then
    txtArea.text = CFURLGetString( url )
    CFRelease( url )
  end if
  '---------------