problems combining two examples

Hi there,

I started diving into the examples and trying to combine 2 of them, “tabar” and “widgets”. I am placing the widgets folder inside the tabar and renaming the main in widgets to per.data so it can be called the tabar program.

Both demos work separately in the present folder setup, but when I want to display/run the widgets program from within the third screen of tabar I get a blank screen. Here’s how I am trying to make it work (the line is commented out since it did not work):

[code]
module(…, package.seeall)

function new()
local g = display.newGroup()

local background = display.newRect(0,display.screenOriginY, display.contentWidth, display.contentHeight-display.screenOriginY)
background:setFillColor(255, 255, 255)
g:insert(background)

local message = display.newText(“Screen 3”, 0, 0, native.systemFontBold, 16)
message:setTextColor(0, 0, 0)
message.x = display.contentWidth*0.5
message.y = display.contentHeight*0.5
g:insert(message)
– local per.data = require( “per.data” ).loadMod()
function g:cleanUp()
g:removeSelf()
end

return g
end

[code]
Please help, I know its the way I am calling it. I think. [import]uid: 95689 topic_id: 16589 reply_id: 316589[/import]

Is per a table ?

If not try this

local per = require( "per.data" ).loadMod() [import]uid: 84637 topic_id: 16589 reply_id: 62089[/import]

Thanks Danny but I tried it. The dot does not seem to be it. I tried calling it “perdata” instead of “per.data” and still nothing. I also tried:

require( “per.data” ).loadMod()
require( “per.data” )
local perdata = require( “per.data” )
[import]uid: 95689 topic_id: 16589 reply_id: 62101[/import]

Maybe the problem lays in the loadMod function? Could you post up the code to that?

What error message do you get ? [import]uid: 84637 topic_id: 16589 reply_id: 62102[/import]

Just a note that file names cannot contain “.” characters if you are using our daily builds. This is now used to specify subolders. If you are using Corona 591 this won’t affect you but it will for the next release. [import]uid: 7559 topic_id: 16589 reply_id: 62390[/import]

Thanks again Danny,

Here’s the error from the terminal:

[blockcode]
Copyright © 2009-2011 A n s c a , I n c .
Version: 2.0.0
Build: 2011.591
The file sandbox for this project is located at the following folder:
(/Users/alexdiaz/Library/Application Support/Corona Simulator/TabBar-70E2E927A807AF4D44B35FC7376C0307)
Runtime error
…ns/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua:14: module ‘per.data’ not found:resource (per.data.lu) does not exist in archive
no field package.preload[‘per.data’]
no file ‘/Applications/CoronaSDK/SampleCode/Interface/TabBar/per.data.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/per.data.lua’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/per.data.blu’
no file ‘/Applications/CoronaSDK/Corona Simulator.app/Contents/Resources/per.blu’
stack traceback:
[C]: ?
[C]: in function ‘require’
…ns/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua:14: in function ‘new’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:23: in function ‘loadScreen’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:39: in function ‘onRelease’
…cations/CoronaSDK/SampleCode/Interface/TabBar/ui.lua:90: in function <…cations>
?: in function <?:215>
[text]
As far as the loadMod it is per.data.lua which is the original main.lua for the widget demo.

At present per.data is in the widget folder which is in the Tabar folder. Maybe I need to take it out of the widget folder so that the Tabar can see per.data. What do you think? But will per.data be able to see the wifget_ios which is inside wideget demo?
(sorry I could not cut & paste here)



[import]uid: 95689 topic_id: 16589 reply_id: 62394[/import] </…cations>

Thanks Tom, I will keep it in mind. [import]uid: 95689 topic_id: 16589 reply_id: 62397[/import]

Danny/Tom

I got it to work finaly, it was a matter of folder structure. I ended up emptying the widget folder and placing its contents in the Tabar folder.

I have another run time error now so I will see what it is.

Thanks for all your help and suggestions! I know I will be back when I encounter another road block.
[import]uid: 95689 topic_id: 16589 reply_id: 62402[/import]

Help with run time error.

I succeeded in combining the two examples that come with corona, “Tabar” & “widget” who I call “per.data” but I have this run time error. I have not changed anything except “screen3” in which I call “per.data”. Let me clarify, if I place an end on module “screen3” it does not give me the menus that come in widget and a run time error. If I omit the end it gives me the menus but I still get a run time error. Run time error either way, I am really confused. Does Module need and end statement? Please see code and run time errors

[code]
module(…, package.seeall)

–function new()

– local g = display.newGroup()

– local background = display.newRect(0,display.screenOriginY, display.contentWidth, display.contentHeight-display.screenOriginY)
– background:setFillColor(255, 255, 255)
– g:insert(background)

– local message = display.newText(“Screen 3”, 0, 0, native.systemFontBold, 16)
– message:setTextColor(0, 0, 0)
– message.x = display.contentWidth*0.5
– message.y = display.contentHeight*0.5
– g:insert(message)
local per_data = require( “per.data” ).loadMod()
– function g:cleanUp()
– g:removeSelf()
– end

– return
end

[code] with end statement
Runtime error
error loading module ‘screen3’ from file ‘/Applications/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua’:
/Applications/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua:32: ‘’ expected near 'end’
stack traceback:
[C]: ?
[C]: ?
[C]: in function ‘require’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:21: in function ‘loadScreen’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:37: in function ‘onRelease’
…cations/CoronaSDK/SampleCode/Interface/TabBar/ui.lua:90: in function <…cations>
?: in function <?:215>

[code] without end statement

Runtime error
…ns/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua:26: attempt to index a boolean value
stack traceback:
[C]: ?
…ns/CoronaSDK/SampleCode/Interface/TabBar/screen3.lua:26: in main chunk
[C]: in function ‘require’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:21: in function ‘loadScreen’
…tions/CoronaSDK/SampleCode/Interface/TabBar/main.lua:37: in function ‘onRelease’
…cations/CoronaSDK/SampleCode/Interface/TabBar/ui.lua:90: in function <…cations>
?: in function <?:215>
[import]uid: 95689 topic_id: 16589 reply_id: 63688[/import] </…cations></…cations>

Do Modules need end statement?

From the tutorials (Modules in Lua):

[code]
–[[
filename:test.lua
–]]

function new()
local object={}
return object
end

function myprint(theObject)
print("The object is ", object)
end
No end statement for Module just for functions !! I am answering my own questions [import]uid: 95689 topic_id: 16589 reply_id: 63831[/import]

Yet in original code for Widgets, iphone.lua is a module and it does have an end statement. What gives? [import]uid: 95689 topic_id: 16589 reply_id: 63833[/import]

The “end” at the end of the iphone.lua module is the end statement for the function “loadMod” that was started at the beginning of the module. Module files don’t use “end” statements. [import]uid: 7559 topic_id: 16589 reply_id: 63834[/import]

Thanks Tom ! [import]uid: 95689 topic_id: 16589 reply_id: 63887[/import]