Jump to content
UBot Underground

Drag A Table Into A Define? A Table Cannot Be A Parameter?


Recommended Posts

I want to create a command that converts a csv file into HTML. That code exists already elsewhere thanks to Ubot, but how to make this into a command? One can only define a variable as far as I can tell. So if you drag a table into the empty parameter filed of the command , that is fine,  but how do you get that to the table called &temp to be replaced by the parameter #table?  One is a variable and the other a table? 

reset browser
table_to_HTML(&temp)
define table_to_HTML(#table) {
    set(#myHTML,"<table border=\"1\">
<tbody>","Global")
    set(#iRow,"-1","Global")
    loop($table total rows(&temp)) {
        increment(#iRow)
        set(#iCol,"-1","Global")
        set(#myHTML,"{#myHTML}
<tr>","Global")
        loop($table total columns(&temp)) {
            increment(#iCol)
            set list position(%keywords,0)
            loop($list total(%keywords)) {
                set(#var,$next list item(%keywords),"Global")
                set table cell(&temp,#iRow,#iCol,$replace($table cell(&temp,#iRow,#iCol),#var,"<strong><big><font color=\"red\">{#var}</font></b></big></strong>"))
            }
            set(#myHTML,"{#myHTML}<td>{$table cell(&temp,#iRow,#iCol)}</td>","Global")
        }
        set(#myHTML,"{#myHTML}</tr>","Global")
    }
    set(#myHTML,"{#myHTML}
</tbody></table>","Global")
}

Original code http://network.ubotstudio.com/forum/index.php/topic/16581-csv-data-to-html-table-conversion-bot/

Link to post
Share on other sites

If you have bot bank this could be as simple as doing this:

set table cell(&temp,0,0,"Name")
set table cell(&temp,0,1,"Age")
set table cell(&temp,1,0,"Sandy")
set table cell(&temp,1,1,37)
set(#html,$html from table(&temp),"Global")
load html(#html)

But also to answer your question &temp will be read as text like you can see here:

set table cell(&temp,0,0,"Name")
set table cell(&temp,0,1,"Age")
set table cell(&temp,1,0,"Sandy")
set table cell(&temp,1,1,37)
ShowTable(&temp)
define ShowTable(#table) {
    alert(#table)
}

It will be passed in fine. But actually, you don't need to do this. In your code the #table var isn't being used and it doesn't need to be used. If you were going to use the command for any table (and not specifically this &temp table) then you could pass in a table and store it in another table to be used with the command. To do that you could use the #table parameter and then convert that to a table using the create table from text command.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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...