Arc Forumnew | comments | leaders | submit | thaddeus's commentslogin

That does it.... Thanks, T.

    (def the-example (value1 value2 value3 value4)
         (or= value1 'Results)
         (or= value2 'wahoo!)
         (or= value3 'ugh!)
         (or= value4 'omg!)
         (prn "Value1: " value1)
         (prn "Value2: " value2)
         (prn "Value3: " value3)
         (prn "Value4: " value4)
)

-----

3 points by absz 6109 days ago | link

You could also wrap your or= sequence in a macro:

  (mac defaults args
    `(do ,@(pair args (fn (var val) `(or= ,var ,val)))))
  
  (def the-example (value1 value2 value3 value4)
    (defaults value1 'Results
              value2 'wahoo!
              value3 'ugh!
              value4 'omg!)
    (prn "Value1: " value1)
    (prn "Value2: " value2)
    (prn "Value3: " value3)
    (prn "Value4: " value4))

-----


omg! It's going to take me a while to read kenny's dsb macro stuff....... my brain just exploded doing a cursory glance.

Thanks for the info. T.

-----


awesome! thanks. T

-----


I see - I didn't know macs transformed code like that.... I just reversed the order of loading my mac's and tada - everything worked!

Thanks! T.

the hack i did turned out to work, but as requested, here it is:

    (mac x-inputs args
      `(tag (table border 0)
         ,@(map (fn ((name label len text))
                  (w/uniq (gl gt)
                    `(let ,gl ,len
                           (pr ',label ":")
                           (if (isa ,gl 'cons)
                               (do (textarea ',name (car ,gl) (cadr ,gl)
                                     (let ,gt ,text (if ,gt (pr ,gt)))(br)))
                               (do (br)(gentag input type  ',(if (is label 'password) 
                                                            'password 
                                                    'text)
                                         name ',name 
                                         size ,len 
                                         value ,text)    (br))))))
   (tuples args 4)))
)

-----


Ok I just looked up details about JSON over the past 10 min. This may seem like a noob question, but hey I'm a noob :).

What's the value in JSON or even XML when I can use a standard http Get/Post Ajax call than runs an arc function outputting my data in html format to any htmldiv I want?

Thanks, T.

-----

1 point by CatDancer 6118 days ago | link

If you want to make an AJAX call from your browser to fetch some HTML from your server and put that data inside a div, you don't need to use JSON for that. Just have your Arc op return the HTML.

Untested, so I apologize for any mistakes:

  (defop grabdata req
    (pr "This is my <i>HTML</i> content!"))
and, in the browser, using for example JQuery (http://jquery.com/) as a convenient way to make the AJAX call:

  $.get("http://yourserver.com/grabdata", function (data) {
    $('#your_div').html(data);
  });
replaces the contents of the div that has the id "your_div" with the HTML content returned by grabdata.

-----

1 point by thaddeus 6118 days ago | link

I don't think I learned anything about JSON, but holy crow jquery is awesome.... The chaining methods alone just made my day! :)

-----

1 point by thaddeus 6127 days ago | link | parent | on: Arc Web Server Security Protocols?

You were correct. I was looking to log into my web-app using https. And in retrospect (you're right again) I could just log into the secure server and show the work that way too. All that being said I still would like to learn setting up https, even for the sake of learning (and I'm sure someday I will need to).

Thanks again. T.

-----

2 points by thaddeus 6127 days ago | link | parent | on: Arc Web Server Security Protocols?

I see.... Thanks. I will forward an Apache server to the Arc server.

I am in the process of buying a "slice" from slicehost and setting up real website (my first time). Local8080 is getting dry as I can't show anyone the awesome things I am doing in arc!

T.

-----

1 point by thaddeus 6140 days ago | link | parent | on: Auto-format function for arc code

That did the trick (I figured this must have been done a million times before) :)

Thanks. T.

-----


ah, I think I see how it can be done... I could bind the uniq-table-name to the symbol of the key. .... makes sense (I think) :).

I hadn't thought of this option because I had been storing the order number in the key position and wouldn't have been able to bind anything to a number like '0'. I was doing this because; calling the table using any table function that return all entries, does not return the order as it was stored, but rather it seems to return them randomly (and the order stored was not sortable). ex. (temp-table) or (vals temp-table).

I hope that made sense.

As for the other question(s),I'll try not to overwhelm....

I'm letting users upload one or many spreadsheets of their choice.... so I then store into a newly generated table which in turn generates html table(s) accessible using their web session. After they close out the web session there's no need to store the data since it will write it back out to a new spreadsheet an store it locally for them. Since I am re-using these functions, i've made them generic, but if they refresh the webpage the html-table functions needs to re-run passing in the correct table-names...so I keep track of which tables had been created for re-loading, hence the storing of the table names as symbols in a table.

I doubt that made sense, but it's what i could muster after 6 hours in front of this code :)

Thanks. T.

As a note my table contained more than just a pair, each entry in the temp-table was storing: order, value, type

-----

3 points by CatDancer 6164 days ago | link

calling the table using any table function that return all entries, does not return the order as it was stored, but rather it seems to return them randomly

Yes, if you need to keep track of things in a particular order (such as the order you added them), you should put them in a list.

Note that you can put the same data in both a list and in a table, if that is what you need for your application.

hence the storing of the table names as symbols in a table

If you want to have a mapping of table names to tables, you can store that in its own table:

  (= tables* (table))
  (= tables*!QYVSn5n1 my-data-table-1)
  (= tables*!UYg47nnb my-data-table-2)
then to get at a particular table

  (let table-name 'UYg47nnb
    (let data-table (tables* table-name)
      ... (vals data-table) etc. ...

-----

1 point by thaddeus 6164 days ago | link

Great! That worked for me.... Not sure why I didn't think of it, but hey I've only been programming for a month now :) Thanks for everyone's help. T.

    (= my-data-table-1 (table))
    (= (my-data-table-1 'drink) 'milk)
    (= (my-data-table-1 'eat) 'eggs)

    arc> (keys my-data-table-1)
    (drink eat)
    arc> (vals my-data-table-1)
    (milk eggs)

    (= my-data-table-2 (table))
    (= (my-data-table-2 'run) 'fast)
    (= (my-data-table-2 'walk) 'slow)

    arc>(keys my-data-table-2)
    (walk run)
    arc>(vals my-data-table-2)
    (slow fast)

    (= tables* (table))
    (= (tables* '0) my-data-table-1)
    (= (tables* '1) my-data-table-2)

    (def load-ordered-tables ()
      (for i 0 (- (len tables*) 1)
        (let current-table (tables* i)
          (pr (vals current-table))
     )
      ))
	

    arc> (load-ordered-tables)
    (milk eggs)(slow fast)nil

-----

1 point by CatDancer 6164 days ago | link

You're welcome!

If it turns out that you just need a list of your data tables, you can do this:

  (= tables* (list my-data-table-1 my-data-table-2))

  (def load-ordered-tables ()
    (each current-table tables*
      (pr (vals current-table))))

-----

1 point by thaddeus 6164 days ago | link

and ..Hey go figure..... I even figured out how to make it work the way I was originally attempting to make it work ! :)

    arc> temp-table
    #hash((0 . (0 hUv086uP)) (1 . (1 CH3w2sdp)))
    
    arc> ((temp-table 1) 1)
    CH3w2sdp

    (= CH3w2sdp (table))
    (= (CH3w2sdp 'run) 'fast)
    (= (CH3w2sdp 'walk) 'slow)

    (def thad ()
       (eval `(vals ,((temp-table 1) 1))))

     arc>(thad)
     (slow fast)
T.

-----

1 point by lboard 6136 days ago | link

Thanks

-----

1 point by thaddeus 6165 days ago | link

ugh - ok that didn't work after all.

The example:

    (= bar [prn "Hello, " _])
worked for you as it did not contain a table function requiring a table name passed in.

so I'm still stumpfied :) lol.

-----


That's perfect - Thank you! T.

-----

More