forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Quick Question

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Wed Mar 08, 2006 6:21 pm    Post subject: Quick Question Reply with quote

I have an edit dialog that im trying to save in an application but it appears as though control characters are causing it to only save the first line if I do a carriage return in the edit field.

Code:

DIALOG ADD,EDIT,EDIT5,205,21,927,389,,,MULTI,BLACK,SCROLL,TABS,WRAP
%%notez = @dlgtext(EDIT5)
  %%saveticket = %%date|%%ticketid|%%source|%%destination|%%message|%%notez


I tried using @trim to no success. What am I missing here or is something else causing this?

WD

_________________
K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Thu Mar 09, 2006 1:47 am    Post subject: Reply with quote

One or both of two possibilities could be causing your problem. I assume you're placing the var "%%saveticket" into a list and saving it to a text file as a flat database. In which case the problem should be apparent by looking at text of the saved file. If there are additional lines between data rows containing a portion of the text from the %%notez field above there are LF and CR characters being saved within the %%notez string. Another problem could be extra flied separator characters are being typed into the edit control by the user to latter be misinterpreted by the parse command.

To resolve the above mentioned you need to validate every char a user types into your program. I use the following, hope it helps.

Code:

#define function,TxtOnly

%%notez = @TxtOnly(@dlgtext(EDIT5))


:TxtOnly
  # This function strips ALL control chars
  # Returns a single line string between #32 - #126
  # Also strips the feild sep char
  # Carrage Returns replaced by White Space
  %R =
  %S = @asc(@fsep())
  %L = @len(%1)
  if @greater(%L,0)
    repeat
      %C = @asc(@substr(%1,%L))
      if @greater(%C,31)
        if @greater(127,%C)
          if @unequal(%C,%S)
            %R = @chr(%C)%R
          end       
        end     
      elsif @equal(%C,13)
        %R = @chr(32)%R
      end
      %L = @pred(%L)
    until @zero(%L)
  end
  exit %R
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Mar 09, 2006 1:47 am    Post subject: Reply with quote

Use @text() instead of @dlgtext()

You might even want to place quotes at both ends of the string since you're
placing %%notez in to another variable

Code:
DIALOG ADD,EDIT,EDIT5,205,21,927,389,,,MULTI,BLACK,SCROLL,TABS,WRAP
%%notez = @chr(34)@text(EDIT5)@chr(34)
  %%saveticket = %%date|%%ticketid|%%source|%%destination|%%message|%%notez
Back to top
View user's profile Send private message Send e-mail
webdaddy
Contributor
Contributor


Joined: 14 Nov 2004
Posts: 151
Location: Raleigh NC

PostPosted: Thu Mar 09, 2006 1:52 am    Post subject: Thanks Reply with quote

That took care of it thank you all very much. I could'nt figure it out. Stupid me..... Thanks again.
_________________
K Wetzel
Programming - Technology - Communications
"The Home of the SLC Security Console"
SLC now available for Linux...
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Thu Mar 09, 2006 2:01 am    Post subject: Reply with quote

Aslan wrote:
Use @text() instead of @dlgtext()



@text is a list function he's using a multi line edit
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Mar 09, 2006 4:32 pm    Post subject: Reply with quote

Ooops, You're right WidgetCoder

I haven't had this problem with control characters in multiline edit boxes before. However I usually place quotes around questionable groups of text.

Code:
 DIALOG ADD,EDIT,EDIT5,205,21,927,389,,,MULTI,BLACK,SCROLL,TABS,WRAP
  %%notez = @chr(34)@dlgtext(EDIT5)@chr(34)
  %%saveticket = %%date|%%ticketid|%%source|%%destination|%%message|%%notez


One thing I have noticed is that not resetting OPTION FEILDSEP back to (|) can sometimes have undesirable results when placing the contents of a control into variables.

Just as a test the following seems to work without any problems:

Code:
Title Multiline Edit Test
  DIALOG CREATE,New Dialog,-1,0,485,234
  DIALOG ADD,EDIT,EDIT1,23,22,442,139,,,MULTI,SCROLL,TABS,WRAP
  DIALOG ADD,BUTTON,BUTTON1,189,215,64,24,DLGTEXT
  DIALOG ADD,BUTTON,Close,190,350,64,24,Close
  DIALOG SHOW
:Evloop
  wait event
  goto @event()
:BUTTON1BUTTON
  %N = 0
  REPEAT
  #Create a string of all ascii characters
  %N =@SUCC(%N)
  %%FILL = %%FILL@CHR(32)@CHR(%N)
  UNTIL @EQUAL(%N,255)
  DIALOG SET,EDIT1,%%FILL
  #Wait a couple of seconds to see %%FILL in EDIT1
  WAIT 2
  %%EDIT1TEXT = @DLGTEXT(EDIT1)
  %%NEWVAR = Add contents of EDIT1 to this string|%%EDIT1TEXT
  INFO %%NEWVAR
  goto evloop
:CloseBUTTON
:Close
  exit
Back to top
View user's profile Send private message Send e-mail
WidgetCoder
Contributor
Contributor


Joined: 28 May 2002
Posts: 126
Location: CO, USA

PostPosted: Thu Mar 09, 2006 4:51 pm    Post subject: Reply with quote

Quoted strings only escape special chars in hard code. You could still have issues with LF/CR and the user entering a field separator. The parse command will still interpret {"sometxt | somemoretxt"} as {"sometxt |} from a saved file. I only use the example above on multi style edits normally I parse edits with @pos() and use @strdel().

There's always more than one way to skin a cat, bad news for cats. Twisted Evil
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group