MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / apiGetFloat

Method apiGetFloat

src/macro.cpp:148–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146 return 0;
147}
148duk_ret_t Macro::apiGetFloat(duk_context *context) {
149 duk_idx_t numArgs = duk_get_top(context);
150 if( numArgs == 2 ) {
151 if( duk_get_type(context, 0) == DUK_TYPE_NUMBER && duk_get_type(context, 1) == DUK_TYPE_NUMBER ) {
152 duk_uint_t row = duk_to_uint(context, 0);
153 duk_uint_t col = duk_to_uint(context, 1);
154 std::string cell_str = macro.table->getCell(row, col);
155 try {
156 double cell_float = std::stod(cell_str);
157 duk_push_number(context, cell_float);
158 } catch(...) {
159 return 0;
160 }
161 return 1;
162 }
163 }
164 return 0;
165}
166
167/**
168 * Flags the given row

Callers

nothing calls this directly

Calls 1

getCellMethod · 0.80

Tested by

no test coverage detected