Jump to content

illegal file characters in user input


jdebuhr

Recommended Posts

I think this is the right area,

Anyway, I have a user interface and on it there is a String Control for the user to enter data. This data is used either in a file name or an Access Database Table name, so the illegal characters are fairly close. What is the best approach to not allowing these characters int he String control when the user types them in?

There might be an easy way, but i am stumped..

any thoughts?

Link to comment
I think this is the right area,

Anyway, I have a user interface and on it there is a String Control for the user to enter data. This data is used either in a file name or an Access Database Table name, so the illegal characters are fairly close. What is the best approach to not allowing these characters int he String control when the user types them in?

There might be an easy way, but i am stumped..

any thoughts?

Try this...

Popup on the string control and turn on "Update value while typing." This will generate a Value Changed event after every keystroke.

Then have an event structure that watches for value changed on the string. Any time the event fires, check the last character of "new value" of the string. If the character is illegal, then wire "old value" into the string's value property.

There might be other ways involving keyboard events, but I'm not familiar enough with the options.

Link to comment
Try this...

Popup on the string control and turn on "Update value while typing." This will generate a Value Changed event after every keystroke.

Then have an event structure that watches for value changed on the string. Any time the event fires, check the last character of "new value" of the string. If the character is illegal, then wire "old value" into the string's value property.

There might be other ways involving keyboard events, but I'm not familiar enough with the options.

That might work THANKS.. although in one instance I wait for the info then update a table based on the info in that string. but now I have a starting point!

Link to comment
And for existing examples, look here.

Thanks there are some great examples there.. I ended up making an Xcontrol (partly to learn Xcontrols, partly as that will work the best) I have a set list of characters that are illegal and will be used in all locations of my code. I did what Aristos suggested, but I am not updating on every character, but after the info is typed it will remove the illegal characters, for me this will be the best way.

Link to comment
Try this...

Popup on the string control and turn on "Update value while typing." This will generate a Value Changed event after every keystroke.

Then have an event structure that watches for value changed on the string. Any time the event fires, check the last character of "new value" of the string. If the character is illegal, then wire "old value" into the string's value property.

There might be other ways involving keyboard events, but I'm not familiar enough with the options.

This works fine as long as the user only enters data by typing them. But if the user copy-pasted data that contained illegal characters this might not work.

To make it work, you would have to check the complete string everytime the event fires.

A similar approach would be to monitor key-strokes while the control is in edit-mode, and add an event check when value changed...

/J

Link to comment
This works fine as long as the user only enters data by typing them. But if the user copy-pasted data that contained illegal characters this might not work.

To make it work, you would have to check the complete string everytime the event fires.

A similar approach would be to monitor key-strokes while the control is in edit-mode, and add an event check when value changed...

/J

Good point. Paste Data should still generate a Value Changed event, but, you're right, at that point you would have to scan the entire string, not just the last character. Hm... I wonder if there's a way to get a VI reference to the Clipboard VI. Brainstorm: The clipboard is visible in the Hierarchy Window whenever you have a subVI copied to the clipboard. I don't have a copy of LV with me right now, but you might try dragging that icon onto a static VI reference -- I have no idea what effect this might have. I know for a fact that LV wasn't built so save references to VIs that are never saved -- there's no path to write down -- so it might work in the dev environment and then crash when you tried to save the VI. Or, heck, there might be an Application property that returns a reference to the Clipboard.

Anyway assuming you can find a way to get a VI reference to the Clipboard VI, you could then intercept the Paste menu event and the Paste Data popup menu event and modify the strings that are about to be pasted on the clipboard VI before allowing the Paste to occur.

This is pretty heavy LV hacking, but it might be a fun backdoor to try to carve.

Link to comment
Anyway assuming you can find a way to get a VI reference to the Clipboard VI, you could then intercept the Paste menu event and the Paste Data popup menu event and modify the strings that are about to be pasted on the clipboard VI before allowing the Paste to occur.

This is pretty heavy LV hacking, but it might be a fun backdoor to try to carve.

Dragging the clipboard icon into a static VI reference does nothing - the reference stays with a question mark. Accessing system VI like BObjectCreate1 and BHierarchy seems to be something a little tricky, and I assume that the clipboard VI is in the same league.

In any case, even assuming that the internal clipboard implementation hasn't been changed since the days before events were available in LV, is there any way to access internal data to that VI, especially without knowing its internal structure?

Link to comment
Dragging the clipboard icon into a static VI reference does nothing - the reference stays with a question mark. Accessing system VI like BObjectCreate1 and BHierarchy seems to be something a little tricky, and I assume that the clipboard VI is in the same league.

Darn. Well, there goes that brainstorm.

Dragging the clipboard icon into a static VI reference does nothing - the reference stays with a question mark.

In any case, even assuming that the internal clipboard implementation hasn't been changed since the days before events were available in LV, is there any way to access internal data to that VI, especially without knowing its internal structure?

The clipboard is just a VI. A VI that never gets saved, true, but just a VI. If we could get a VI reference to it, we could break it down using any of the VI properties/methods. It would take some doing, but I don't think it'd be impossible.

Link to comment
Darn. Well, there goes that brainstorm.

Actually, it seems that in 8.2 you can drag the icon into a static reference, but the reference itself has a null value. Also, deleting the static reference clears the clipboard, which strikes me as sort of a bug, albeit a minor one.

The clipboard is just a VI. A VI that never gets saved, true, but just a VI. If we could get a VI reference to it, we could break it down using any of the VI properties/methods. It would take some doing, but I don't think it'd be impossible.

I realized it was a VI. I was actually confusing text and image copying (which seem to be done in seperate functions) with copying pieces of code (which is copied into a diagram).

In any case, you could break down the VI diagram for sure using the diagram properties etc., but can you tell when another event structure fires? As far as I remember you can't, but maybe this was added in more recent versions.

Unless maybe it's a user event and you can get a reference to it and register it in another structure?

In any case, since the value change event is fired when pasting, I think I would limit the changing to the current VI.

Link to comment
Anyway assuming you can find a way to get a VI reference to the Clipboard VI, you could then intercept the Paste menu event and the Paste Data popup menu event and modify the strings that are about to be pasted on the clipboard VI before allowing the Paste to occur.

The ability to intercept Copy-Paste operations would be a nice addition to the event structure, but I don't think it would completely solve the issue here.

We would still face problems when a user selects a portion of the string, and then enters new characters (possibly by copy-paste or drag-n-drop).

I made a little VI, that checks the key-down event and also the Value change event. When illegal characters are detected it just opens a dialog.

Download File:post-5958-1167215079.vi

/J

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.