Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

I am Master of Overcomplification.. Can this be simplified?

 [1/7] from: Izkata::Comcast::net at: 9-Jan-2005 13:17


Form1: ["Hours=" "(F1P1/text)" "&" "MP=" "(F1P2/text)" "&" "GP=" (F1P3/text) "&" "VocPromo=" "(F1P4/text)"] view layout [ F1P1: field "" F1P2: field "" F1P3: field "" F1P4: check-mark "" btn "Send" [LoadPage/post (Url) ( to-string compose load to-block rejoin Form1)] ] Note: I am working on creating a web browser. So far, Forms, Images, and Text work. This was created by the browser loading a test form, that's why I have the Form1 block before anything else and can't create it inside the send button. Any way to simplify ( to-string compose load to-block rejoin Form1) ? -Izzy boy

 [2/7] from: carl:cybercraft at: 9-Jan-2005 21:51


On Sunday, 9-January-2005 at 13:17:14 you wrote,
>Form1: ["Hours=" "(F1P1/text)" "&" "MP=" "(F1P2/text)" "&" "GP=" >"(F1P3/text)" "&" "VocPromo=" "(F1P4/text)"]
<<quoted lines omitted: 12>>
>before anything else and can't create it inside the send button. >Any way to simplify ( to-string compose load to-block rejoin Form1) ?
Do you really need the parens in strings in Forml? As I think without them just a REJOIN should give the same results. ie... Form1: ["Hours=" F1P1/text "&MP=" F1P2/text "&GP=" F1P3/text "&VocPromo=" F1P4/text] and... btn "Send" [LoadPage/post (Url) rejoin Forml] I might've mis-read what you were trying to do, or course... -- Carl Read.

 [3/7] from: Izkata::Comcast::net at: 9-Jan-2005 15:24


----- Original Message ----- From: "Carl Read" <[carl--cybercraft--co--nz]> To: <[rebolist--rebol--com]> Sent: Sunday, January 09, 2005 3:11 PM Subject: [REBOL] Re: I am Master of Overcomplification.. Can this be simplified?
>>Form1: ["Hours=" "(F1P1/text)" "&" "MP=" "(F1P2/text)" "&" "GP=" >>"(F1P3/text)" "&" "VocPromo=" "(F1P4/text)"]
<<quoted lines omitted: 23>>
> btn "Send" [LoadPage/post (Url) rejoin Forml] > I might've mis-read what you were trying to do, or course...
I see what you mean, and I did try it that way - but it wouldn't let me.. Here's basically how it gets the tags and such for the form.. Load/markup to separate the tags, so a tag for, say, a field becomes <INPUT Type="Text" Name="Whatever"> it parses out the Type and Name, then sticks the Rebol form (using 'field) onto the end of the file that becomes the layout, and adds that F1P1/text onto Form1 block - Append and Insert won't let me simply stick it on the way you suggested, so I had to make a (huge) workaround. It would have been far simpler had I configured it for 1 form a page, but I've seen web pages with 3+ forms.. including one of my own XD If you need it I'm willing to post part of my code

 [4/7] from: carl:cybercraft at: 9-Jan-2005 23:51


On Sunday, 9-January-2005 at 15:24:50 Izkata wrote,
>If you need it I'm willing to post part of my code
Sure. And include a few examples of the raw data it's supposed to process and what the end results are meant to look like. -- Carl Read.

 [5/7] from: inetw3::mindspring::com at: 10-Jan-2005 0:19


Hello Izkata, It looks like you may want to reduce the Form1 block, before the load/page btn is pressed. I could be wrong. btn "Send" [LoadPage/post (Url) to-string reduce Forml] Hey, I have a Rebol Browser i've put together. But because i've never really programmed before i think i may be the real Master Overcomplication. It reads local and http files and render them also to VID layout, but if the HTML code does'nt conform to some XHTML rules, like you must have closing tags such as... </p>, </table>, and no improper nested tags, it lays it out as it is. It will still view the pages, but it's looks is not close enough to what most browsers would show with bad HTML. My approach for a send button. I use my %quickparser.r script as a part of my browser. I have'nt put together a send button, but it would have to go something like this. btnSend: func [ attributename /local Form1][ Form1: [] getattribute attributename append Form1 reduce [attribute "=" attvalue "&"] ] <input id=Form#1 type="send" onclick="btnSend{Hours}btnSend{MP} btnSend{GP}btnSend{VocPromo}"]LoadPage/post.Url.to-string.reduce.Form1 /> You could put the attributes you want in a block and use... onclick="foreach.attribut.attributename[btnSend.attribut]etc."] /> you need to parse the html to Form#1 to "onclick" and copy it as something to "/>" replace something "." { } replace something "[" " [" replace something "]" "] " and then...... btn send [LoadPage/post(Url) to-string reduce something ]

 [6/7] from: Izkata::Comcast::net at: 10-Jan-2005 6:13


Note the "do rejoin" lines - I hate using that. But it's all I could think of when I wrote this. Also, last night while trying to sleep, I thuoght up a far better way to do this - so please -don't bother even messing around until I test it out- - I want to send this before I forget just in case the idea doesn't work and I woulda needed to send it later - I guaruntee I'd forget. Here's a test form I was using: (Note: I am not even bothering with type=reset) <FORM action="Levels2.html" method="Post"> <P> Experience for Level: <INPUT type="text" name="Level"><BR> <INPUT type="submit" value="Send"> <INPUT type="reset"> </P> </FORM> Here's the lines that MakeForm adds to the layout: F1P1: field "" button "Send" [LoadPage/post (to-url "Levels2.html") ( to-string compose load to-block rejoin Form1)] And what Form1 ends up looking like (when 'mold is used) ["Level=" "(F1P1/text)"] MakeForm: func [ FormTag [tag!] Page ][ Tag: mold FormTag parse (mold Page/1) [ thru {action=} copy ToPage to { } thru {method=} copy Method to {>} ] while [string? (Load ToPage)][ToPage: load ToPage] while [string? (Load Method)][Method: load Method] FormCount: FormCount + 1 FormPart: 0 append Forms rejoin [{Form} FormCount] do rejoin [{Form} FormCount {: copy []}] ;this would create the block Form1, as I used in my last example while [true][ Page: next Page if find Page/1 {INPUT} [ parse (mold Page/1) [ thru {type=} copy Type to { } ;this'll find whether it's a field, checkbox, or other thru {name=} copy Name to {>} ] while [string? (Load Type)][Type: load Type] while [string? (Load Name)][Name: load Name] FormPart: FormPart + 1 if (Type = "text") [ if (FormPart > 1) [do rejoin [{append Form} FormCount { "&"}]] ;add an "&" if it's not the first item in the form do rejoin [{append Form} FormCount { "} Name {="}] ;now add the "Something=" part.. do rejoin [{append Form} FormCount { "(F} FormCount {P} FormPart {/text)"}] ;and add the Rebol script that makes it work write/append %TMP.txt rejoin [newline { F} FormCount {P} FormPart {: field ""}] ] if (Type = "checkbox") [ if (FormPart > 1) [do rejoin [{append Form} FormCount { "&"}]] ;same comments as in "Type="text"" do rejoin [{append Form} FormCount { "} Name {="}] do rejoin [{append Form} FormCount { "(F} FormCount {P} FormPart {/text)"}] write/append %TMP.txt rejoin [newline { F} FormCount {P} FormPart {: check-mark ""}] ] ] if Page/1 = </form> [break] ;If it found the end form tag, get out of the loop because it's done ] if (Method = "Post") [ write/append %TMP.txt rejoin [ newline { button "Send" [LoadPage/post (to-url "} ToPage {") ( to-string compose load to-block rejoin } rejoin [{Form} FormCount] {)]} ;Add "Send" button newline {;} mold Form1 ;I added this line to test it and see what was happening. This is what gave me the idea last night. ] ] if (Method = "Get") [ write/append %TMP.txt rejoin [ newline { button "Send" [LoadPage/get (to-url "} ToPage {") ( to-string compose load to-block rejoin } mold do rejoin [{? Form} FormCount] {)]} ;Sedd "Send" button newline {;} mold Form1 ;I added this line to test it and see what was happening. This is what gave me the idea last night. ] ] ]

 [7/7] from: Izkata::Comcast::net at: 10-Jan-2005 19:57


Yay, my new idea worked. And without sticking unfortunate "do rejoin" lines in there! -Izzy

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted