Codea 3.0 (184)

@Simeon My readProjectTab was in setup() and just a few lines of code to prove what was happening.

@dave1707 oh okay thanks, must be something else then. I’ll have it sorted before release

@Simeon my readLocalData was in setup()

New build should have fixes for the readData/Tab functions and reference menu.

@simeon, good, readLocalData now working again!

@Simeon, i notice if the dependence name is long, the size of the corresponding checkbox can become very small.

@Simeon readProjectTab works now. readProjectTab doesn’t find a new tab until Codea is closed and reopened. You said that was due to the way the File system works or something like that. That could be a problem in programs that create tabs and then try to read it again later in the code.

@Simeon Double tapping a word and then tapping reference doesn’t always show the info of what was highlighted. It would open the reference list but that’s it. The first thing I tried for reference info was readProjectTab. The reference list was opened but that’s as far as it went. I tried several other words, but there wasn’t a pattern as to what worked and what didn’t. What would be nice is if it worked like doing a search from within the reference list. For instance, if I search on camera from within the reference list, it shows a list for all of the camera usage.

@Simeon Can you put the two arrow keys back in the top line of the keyboard. I’m finding more and more situations where I use them and using the long press on the space bar to move the cursor isn’t working as well as those keys. Or is there a reason you removed them and can’t put them back.

@dave1707 I removed them because the two finger drag anywhere on the keyboard just seemed nicer (it’s what I use when I want to move the cursor). But I’ll look at putting them back.

Thanks for the note on the reference, will fix.

On the readProjectTab issue, are you saying that if you create a new tab (like Do → New Class) then try to use readProjectTab to read it’s contents it won’t load?

@Simeon Try this code. It will create the tab test4 with save, but won’t find it with read. If you close the project and run it, same error. If you close Codea then open the project and run it the code, it reads it.

I ran into something else when I was creating this code. I saved a tab, but later I deleted it. I closed Codea and from another program that reads each project and each tab, it found the name of the deleted tab, but gave an error because the tab data wasn’t there. So when I deleted the tab, the data was deleted, but the tab name was still associated with the project until I closed Codea.

function setup()
    saveProjectTab("test4","--qwertyuiop")
    a=readProjectTab("test4")
    print(a)    
end

@Simeon I tried using your two finger drag on the keyboard and I find it really hard to use. Here’s one example where I miss using the arrow key. Try keying what I have in the first tab in the second tab. Normally I would tap the “” key, key the letter a, then tap the right arrow to move the cursor past the ". I would tap the , key then the “” key and key the letter b. And so on. There are a lot of situations where I need to move the cursor one position to the right and tapping the arrow key is fast and easy.

function setup()

    tab={"a","b","c","d","e","f","g"}

    tab={}

end

@dave1707 I do see your point on this and there is room for the key on the keyboard. I’ll play with the software keyboard and try your examples then see what works, it’s likely I’ll re-include the key

@dave1707

In build 179 when you want to use readProjectTab on the current project in the new code editor you should long-press the play button in the top right and choose “Save and Run”

Saving a tab and attempting to read it should work now, and you shouldn’t need to reload Codea to read tabs correctly out of projects

The new tabs you create may not appear immediately in the code editor if you exit the runtime straight away, but the hope is that they pop in shortly after they are created

Some background on why this is necessary: the new code editor doesn’t commit projects to disk when you run them. Writing all the code to disk from RAM can be expensive (especially if another app on your iPad is also editing the project) and not really necessary for most Codea projects — because most don’t self-modify with saveProjectTab

But readProjectTab et al. expect that the data on disk is always up-to-date, which may not be the case when you run a project now

I’ve put in a hidden feature you can use to ensure that when you run your project it writes to disk first. Long press the play button in the top right for ~2 seconds and you will get a dialogue to “Save and Run”

You need to do this is if you have added or deleted tabs, or modified your code and want to use readProjectTab to read these changes in the current project

(Alternatively you can close and open your project again, but this is faster)

@Simeon Version (179). Thanks for putting the arrow key back, that makes writing code a lot easier. Also, long pressing on the arrow key allows you to move the cursor around. That’s always worked in previous versions.

The Save and Run works great.

I’m still trying to figure out the reference changes.

One thing I’ve notice when I was testing the new changes, the indentation after pressing return stops working. If I key for z=1,10 do and press return, the cursor on the next line is left justified instead of being indented. When I key function somename() and press return, the cursor goes to the next line left justified and doesn’t add the end keyword. It doesn’t happen all the time and I’m not sure what causes it. I’ll play around with that more.

@Simeon Suggestion. I was testing the save and readProjectTab and I though the save wasn’t working. I code in portrait orientation and the editor looks a little different than landscape. When I tapped the tab list, it wasn’t showing all my new tabs in the drop down. That’s when I realized you only show 9 tab names when in portrait orientation and you have to scroll the list up to see the rest. When you have more tabs then what you show, can you add a message to the list, something like scroll down for more tabs. I very seldom use tabs, so that’s up to you.

@Simeon Some weird things happening. I tried the below code again that was causing an error before where it wouldn’t find the created tab unless I closed Codea. You added a Save and Run option to fix that. I tried running the below code just by tapping the run icon expecting to get an error, but I didn’t, and it created the tab and read it correctly. I then changed both test4 to test24 and ran it again. No error. I exited back to the editor and after about 2 seconds the test24 in the code changed back to test4 without me doing anything. Does that mean new code changes don’t get saved unless the Save and Run is done.

function setup()
    saveProjectTab("test4","--qwertyuiop")
    a=readProjectTab("test4")
    print(a)    
end

@Simeon After running the above code and closing the editor, I went back in to try something else. I added an empty function, ran the code, exited to the editor and after a second or 2 the new function disappeared. I went to try it again and when I keyed in the empty function, I was getting the left justification problem.

PS. I closed Codea and got something to eat. Later I tried the above code again, but I wasn’t getting the code to switch back. I was still getting the left justification problem though.

@dave1707 thank you for all your feedback. I’ll try reproduce the indentation issue

Good point on the tab list — it’s actually a bug that it’s showing the list on iPad in portrait. It should be using that on iPhone and when iPad is in split-screen. I’ll think about how to make the scrolled off region more obvious

On your issue:

I tried the below code again that was causing an error before where it wouldn’t find the created tab unless I closed Codea. You added a Save and Run option to fix that.

This is not quite what is happening with “Save and Run.” Basically your initial code (save tab, read tab) should work without requiring Save and Run, because in this case saveProjectTab immediately creates the file on the file system, and readProjectTab can immediately read it without issue

The time when you want to use Save and Run is if you want to readProjectTab for code you’ve just modified in the new editor. So if you have deleted, created or edited tabs and hit the run button, the readProjectTab command might read the old version (which is sitting on disk, or it exists but should be deleted, etc)

So you are right in observing that new code changes won’t propagate to the readProjectTab API unless Save and Run is used

@Simeon Thanks for the clarification on the Save and Run. I guess I didn’t understand it fully. One question with it. When you long press the run icon, you give two options, Run Only or Save and Run. Do you need the Run Only. Isn’t that the same as just tapping the run icon. That would mean you only need the Save and Run option.