Git Product home page Git Product logo

Comments (4)

jjatria avatar jjatria commented on June 21, 2024

Further weirdness. It turns out that assigning the ID of a newly created object makes printing come back, but nothing gets printed if the ID is not assigned to anything. The following will work:

clearinfo
file$ = temporaryDirectory$ + "/temp.praat"
writeFileLine: file$,
  ... "a = Create TextGrid: 0, 1, ""Hello"", """""
appendFileLine: file$,
  ... "writeInfoLine: ""Hello"""
a = nocheck runScript: file$

But removing the ID assignment:

writeFileLine: file$,
  ... "Create TextGrid: 0, 1, ""Hello"", """""

makes the problem come back.

What is going on?

from praat.

PaulBoersma avatar PaulBoersma commented on June 21, 2024

What about this one:

clearinfo
file$ = temporaryDirectory$ + "/temp.praat"
writeFileLine: file$,
... "a = Create TextGrid: 0, 1, ""Hello"", """""
appendFileLine: file$,
... "writeInfoLine: ""Hello"""
b = nocheck runScript: file$
deleteFile(file$)
appendInfoLine: b

b will contain the unique id of the TextGrid...

from praat.

PaulBoersma avatar PaulBoersma commented on June 21, 2024

Or this:

a = nocheck writeInfoLine: 10
appendInfoLine: "<<", a, ">>"

This writes <<10>>, but without the nocheck it just writes <<1>>, which is the (meaningless) return value of writeInfoLine. Here you can see that using nocheck ignores the return value of the function (either runScript or writeInfoLine), so that the assignment only finds whatever was in the diverted info return buffer before. The return values of writeInfoLine and runScript are meaningless, so normally you would never see this interaction happen.

from praat.

jjatria avatar jjatria commented on June 21, 2024

The return value of writeInfoLine etc. are in general quite meaningless, because they always return 1. But they do so as far as they succeeded (or am I getting this wrong?). I actually do use the return value of runScript() in a procedure I wrote to try to implement a try ... catch style block. The idea being that you could write

include path/to/try.proc
call try
  ... # Next line has a typo            \n
  ... Crate TextGrid: 0, 1, "Hello", "" \n

if try.catch
  writeInfoLine: "There was an error"
endif

and not worry about whether or not your main script would fail (note how in that procedure I have to create an object as a placeholder, precisely to navigate around this problem, which back then was a lot more obscure to me).

I think the behaviour of nocheck is confusing. We've talked about this with regards to code like nocheck @procedure(), which did not do what I expected (disregard errors in the execution of that procedure) but instead skipped the procedure altogether.

And with the example you wrote, it seems nocheck also allows you to catch what is being written to the Info window?

What exactly does nocheck do? Or better yet: what do you consider to be the purpose of nocheck?

from praat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.