Jump to content

Urwigo field vetting


Spire67

Recommended Posts

I have built a cartridge using the Urwigo builder.

I am now in the process of testing it.  I have several input fields in the cartridge.  They are all numeric fields.  In testing the cartridge I have entered alpha characters and found that it simply quits out of question with no message.  You then have to exit the zone and re-enter it to get it to fire the question again.  Is there any way of dealing with the user inputting their response in the wrong format so that it gives an appropriate message and then allows them to re-input their response?

Link to comment
2 hours ago, Spire67 said:

I have built a cartridge using the Urwigo builder.

I am now in the process of testing it.  I have several input fields in the cartridge.  They are all numeric fields.  In testing the cartridge I have entered alpha characters and found that it simply quits out of question with no message.  You then have to exit the zone and re-enter it to get it to fire the question again.  Is there any way of dealing with the user inputting their response in the wrong format so that it gives an appropriate message and then allows them to re-input their response?

You can do it a couple of different ways. Here's a way I've used.. in LUA.

function ValidateCode(code)
if not IsNumeric(code) then
var_codeValid = false
return
end

function IsNumeric(var)
local num = tonumber(var)
if num == nil then
return false
else
return true
end
end

 

Link to comment
6 hours ago, bflentje said:

You can do it a couple of different ways. Here's a way I've used.. in LUA.


function ValidateCode(code)
if not IsNumeric(code) then
var_codeValid = false
return
end

function IsNumeric(var)
local num = tonumber(var)
if num == nil then
return false
else
return true
end
end

 

Thanks for the response.  Can that be added to code written through the urwigo app?  If so how?

 

Link to comment

I have inserted a LUA User code at the start of the flow for the input.  See attached screen shot.  The first script threw up an error "Expecting 'end'. Around line 5 character 4.

The second script was error free but then did nothing to trap the input of an alpha character.  Does the (code) need to be changed to the name of the input variable and if so how do identify what that is?  Thanks

Screenshot (141).png

Link to comment

I use Earwigo so don't know how your tool implements it. But my functions are located in the Author Script block. Once it's there..

- I have a boolean variable named var_codeValid
- I have an expression named codeValid
- In the GetInput event, first step is to do a Lua statement: 
ValidateCode(var_answer)
- followed by If/Then, checking the expression. 

You should get the gist of it??

 

This was my first attempt at this in a builder tool so I would definitely do it differently if I wrote it today. But it works.

Capture.PNG

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...