Tap Forms app icon half
Tap Forms Forum text image
Blue gradient background

Exchange tips and ideas with the Tap Forms community

Search Results for 'script'

Viewing 15 results - 2,401 through 2,415 (of 2,984 total)
  • Author
    Search Results
  • #36724
    Sam Moffatt
    Participant

    I personally wouldn’t want to write a script without a physical keyboard regardless of platform and I don’t think I’d like to do too much hard core editing on the iPhone/iPod form factor. There are two reasons for wanting an actual keyboard: being able to quickly type special keys and screen real estate. There’s a detailed explanation of both at the bottom if you’re interested. Fortunately you can get a cheap Bluetooth keyboard and that will help you solve both of those problems.

    That said sooner or later I’d suggest grabbing a desktop to work on so that you can use a web browser easier and more importantly Google! You’re learning, you’re going to want to easily copy and paste stuff from the web and try things. On any iOS device, that’s going to be cumbersome. The new iPadOS stuff might make it better but at the cost of screen real estate again. On a Mac you can Command+Tab between two apps to easily copy and paste code to try. It’s a little easier to reason about importing stuff from the forums with a Mac device in a way that isn’t quite as straight for on iOS due to limitations there.

    I mentioned elsewhere (or at least thought I did) that you can go to OWC/macsales.com and pick up a cheaper, older generation, second hand Mac Mini that likely has more than enough power to run Tap Forms, hook it up to a monitor or even TV, get a keyboard and mouse (potentially Bluetooth again) and start working. There is an extra cost but if I wanted to learn, I’d prefer to do it on the desktop rather than on the phone. And if you buy the app on both platforms (you do need to buy for each of iOS and Mac), you can use the P2P sync to keep both the phone and desktops up to date (make sure both are online at the same time!).

    Detailed reason why keyboard:

    The first one is more due to how programming languages rely on keys that you don’t normally type when you’re writing text: ,, ', ", /, =, ;, |, &, !, {, }, [, ], ( and ). Writing these on a keyboard is an extra shift key for many of them however on iOS you need to go to the first layer of numbers and symbols, then sometimes the second layer and sometimes (like the quotes), need to long tap. On top of that the iOS keyboard by default will want to insert “smart” quotes and that’s going to mess things up in weird and wonderful ways if you don’t remember that long tap the quotes. I’ve been through that nightmare before with calculation fields and warn about it frequently as an iOS hazard. I also have multiple languages enabled, so every so often I tap the change language button which is right next to the symbols/numbers button and then it’s a pain to fix that. A real keyboard avoid most of these hazards and impediments.

    The second is a little less obvious early on: you want to see as much code as you can. On my iPhone 7 with the keyboard up I get:

    – landscape mode: ~9 lines of text and 64 characters per line
    – portrait mode: ~21 lines of text and 33 characters per line

    When I take the keyboard offscreen I get:

    – landscape mode: ~16 lines of text (7 more lines!)
    – portrait mode: ~32 lines of text (11 more lines!)

    If you have a dedicated keyboard, you can get these lines back that help immensely in being able to understand. I would go for landscape mode because that gives you more character width even though it’s obviously half the lines of text. What I end up seeing happening is that in portrait mode, the lines wrap more frequently and this cuts down the effective number of lines that you have visible whilst making it harder to read due to the wrapping. For perspective the old DOS terminals used to supported 80 characters per line and 25 lines.

    This ended up a little wordy, hopefully the details help.

    #36723
    Richard Riffle
    Participant

    OK, I’m interested in writing scripts but have no Javascript experience. Further, I don’t have a Mac, only iPhones/iPods to write and debug the scripts. Is it feasible to learn to write scripts this way? Are there additional tools available for iPhone/iPod which would help? Any other options? Or should I buy a Mac?

    I have made a few brief attempts at using some of the included script fragments in Tap Forms and was able to retrieve field codes but couldn’t use those to retrieve the value of a record. The experience suggested to me that I may need a better environment to write and debug the script… among other things.

    Thanks in advance!

    #36722
    Daniel Leu
    Participant

    I don’t really see the motivation to move records since you can hide them using saved searches. With a script you could even hide linked records where the parent is hidden.

    Using a script you should be able to create new records in another form and copy the data over.

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #36714
    john cesta
    Participant

    Has anyone messed with the movie script to get the characters/cast into tapforms?

    I’ve tried some various things but not been able YET to do this.

    Thanks

    #36709

    In reply to: Why doesn't this work?

    D J Leason
    Participant

    @ Brendan

    I agree! I wish I was following his JavaScript tutorial!
    You hear that @ Daniel Leu?

    #36705

    In reply to: Why doesn't this work?

    D J Leason
    Participant

    @Brendan

    Thank you Brendan! That works! I went back to the tutorial and ran it again and in their ‘Try it yourself’ editor. It runs in an HTML doc type and has the following line to get x:

    document.getElementById(“demo”).innerHTML = x;

    <!DOCTYPE html>
    <html>
    <body>

    <h2>JavaScript Functions</h2>

    <p>This example calls a function which performs a calculation and returns the result:</p>

    <p id=”demo”></p>

    var x = myFunction(4, 3);
    document.getElementById(“demo”).innerHTML = x;

    function myFunction(a, b) {
    return a * b;
    }

    </body>
    </html>

    #36703

    In reply to: Why doesn't this work?

    Brendan
    Keymaster

    Hi DJ,

    Daniel is correct in his sample. However, you may be able to just add return x; after your second last } but before the last }. Basically your function is returning x, but you’re not returning the result of x to the Script() function.

    #36699

    In reply to: Why doesn't this work?

    D J Leason
    Participant

    @John cesta

    Because x is the variable where the result 12 will be stored.Also I can change the arguments there. That’s what I got from it anyway. I’m new to JS and I copy and pasted it exactly as it was in the tutorial where it worked fine.

    When JavaScript reaches a return statement, the function will stop executing.
    If the function was invoked from a statement, JavaScript will “return” to execute the code after the invoking statement.
    Functions often compute a return value. The return value is “returned” back to the “caller”:
    Example
    Calculate the product of two numbers, and return the result:

    var x = myFunction(4, 3);   // Function is called, return value will end up in x

    function myFunction(a, b) {
      return a * b;             // Function returns the product of a and b
    }
    The result in x will be:
    12

    #36697

    In reply to: Why doesn't this work?

    Daniel Leu
    Participant

    You have to define your function outside of Script():

    function myFunction(a,b){
       return a * b;
    }
    
    function Script(){
       var x = myFunction(4, 3);
       return x;
    }
    
    Script();

    Cheers, Daniel

    ---
    See https://lab.danielleu.com/tapformspro/ for scripts and tips&tricks

    #36694
    D J Leason
    Participant

    Trying to learn some Javascript so I can use the script field. I replaced the Hello World code with code from a W3Schools tutorial but it doesn’t work. What am I doing wrong?

    Attachments:
    You must be logged in to view attached files.
    #36683
    john cesta
    Participant

    Best way to display fields side by side….

    DOB Age

    When I use concat it gets messed up because one is a date and one is a number.

    Is there a better way to write a record script to simple display fields side by side for viewing?

    I’m sure there is.

    Thanks,

    #36682
    Sam Moffatt
    Participant

    You would have a script field that is connected to the check box and then any time the checkbox state was toggled, it’d run the script and it could change the colour accordingly.

    For John’s original today() == meetingDate example, I think you would have to tell Tap Forms to re-evaluate the calculations once a day if using a field script or have a form script that you run once a day to scan and update the record colours.

    #36680
    matt coxon
    Participant

    hi Brendan, this would be excellent, will it be conditional, example .. I have a checkbox record field “hot list” I use this for the most important records within a form. Currently I select all “hot list” via a filter, and then manually mark all as red. (and when no longer in the hot list I have to manually de-select the color) Would be good if I can automate (via a script)

    thanks
    Matt

    #36663

    In reply to: Importing

    Sam Moffatt
    Participant

    I’m not as sure about how to do this on iPad as I do most of this on the Mac and sync it over using CouchDB to my iOS devices however you should be able to do all of this on iOS as well.

    1. I duplicate the entire document and then export the forms to a new document from time to time. If you use the duplicate option in Tap Forms on a document, it’ll give it a new document ID and isolate it for you. This is useful for testing, making sure sync doesn’t accidentally go somewhere you don’t intend and gives you the confidence that you can delete everything and start from scratch. The other thing I do is export the form template and load it up into temporary documents to toy with things.

    2. You can recalculate either an individual record or all records in a form. To recalculate an individual record, on iOS you can drag down a record to recalculate it’s formulas and on the Mac use the refresh button at the bottom of the record layout or use the menu to go to “Records” > “Refresh Selected Record”. To recalculate an entire form, on iOS you can drag down the record list to recalculate and on the Mac use the refresh button at the bottom of the list for the view you are using or use the menu to go to “View” > “Refresh Records List”. Tap Forms will automatically recalculate a calculation when you change a referenced field unless you have the calculation field set to “Calculate only one time” (useful mostly for functions that use UUID() or some other fixed, one time operation). Similarly when you click refresh/drag down, it will ignore any “Calculate only one time” fields as well.

    That said if you’re happy to wait a moment, refreshing an entire form isn’t the end of the world. I do it on my calculation and script heavy forms all of the time and it’s only a mild inconvenience. Many of my script fields also invoke web API’s hosted within my network, so I can easily see when I make that mistake. I do wish if Tap Forms notices it’s taking longer than a few seconds to recalculate that it gave some sort UI popup indicate where it’s at with stuff.

    #36659
    Michael Harding
    Participant

    Hi Sam. Again: many thanks for your help. It puzzles me that this formula once worked for me and continues to for me in one area of my form (the ‘discounting area’ versus the ‘unit cost’ calculation).

    Nevertheless, I’ve spent hours trying to come to grips with it and did succeed in getting one cell to link to the total cost calculation result. Replicating the formula for other cells didn’t and doesn’t work.

    I’ve looked everywhere and into everything to divine why this is so. Nothing seems to present itself and my analysis suggests that the problem isn’t so much the equation/scripting but an error somewhere else.

    The cells are all correctly set up as number cells. They link in the correct order, as Brendan suggested doing a few days ago. But there must be something incorrect in the way Tap Forms is seeing the cells.

    I have been through the various cells checking and checking and just don’t see where the problem lies.

Viewing 15 results - 2,401 through 2,415 (of 2,984 total)