Hello Guest it is May 20, 2019, 03:08:11 PM

Author Topic: Variables reading and writing  (Read 9323 times)

0 Members and 1 Guest are viewing this topic.

Re: Variables reading and writing
« Reply #20 on: May 17, 2014, 08:37:36 PM »
Looks like you've done good Terry, do they spit out the correct code?
I too like the bolt hole pattern wizard to use as a template.

Offline BR549

*
  •  6,865 6,865
    • View Profile
Re: Variables reading and writing
« Reply #21 on: May 17, 2014, 08:43:11 PM »
NOPE still can't do it without example code. I am just cutting and pasting here from Brians original example. THAT is not programming that is fishing with rocks, sooner or later you WILL hit a fish in the head and have supper.

I do have a question on wizards. I need to be able to LOAD the program on close of the Wizard. The Wizard uses this code to gather the FileName to save.

I cannot figure out WHAT VARIBLE it saves the NAME as. I need that NAME to be able to open the file in Mach4 before the wizard closes.

I use MsgBoxes to try and test all the variables I could think of and it always reports NIL. It would appear that it uses the local Variable "file" but I get NIL when I display that string right after that function.

  -- End of Gcode Write fILE to DIR    
                 local file = wx.wxFileDialog(panel, "Select Gcode File Name","",""," Tap files (*.tap)|*.tap",
                        --wx.wxFD_SAVE,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
                         wx.wxFD_SAVE + wx.wxFD_OVERWRITE_PROMPT,wx.wxDefaultPosition,wx.wxDefaultSize, "File Dialog" );
             --wx.wxMessageBox(tostring(file))
    

        if (file:ShowModal() == wx.wxID_OK) then
            local path = file:GetPath()

            --wx.wxMessageBox(tostring(path))

            io.output(io.open(path,"w"))
            io.write(gcode)
            io.close()
        end
        SaveSettings()
    end)



IT DOES write the correct file name on the save BUT what IS the file name  ????????



HIYA CRAIG, I have the code that runs the functions I just need to convert it to LUAISM  Right noww it just posts the Safety Blocks AND the file end Blocks.

I ran out of ROCKS , (;-) TP
« Last Edit: May 17, 2014, 08:48:51 PM by BR549 »
Re: Variables reading and writing
« Reply #22 on: May 17, 2014, 10:29:39 PM »
With a lot of struggling, a little direction & help, I now have a Wizard that shows the axis DRO's in real time (set to 100ms scan) and that can be pinned to the screen's top. This uses iRegs0 to Write and Read the small floating popup. From this template, I can now create several other useful screen popups and also add to this as my Screen MPG

Took a whole lot of rocks, Terry  :P

Offline BR549

*
  •  6,865 6,865
    • View Profile
Re: Variables reading and writing
« Reply #23 on: May 17, 2014, 10:42:57 PM »
With a lot of struggling, a little direction & help, I now have a Wizard that shows the axis DRO's in real time (set to 100ms scan) and that can be pinned to the screen's top. This uses iRegs0 to Write and Read the small floating popup. From this template, I can now create several other useful screen popups and also add to this as my Screen MPG

Took a whole lot of rocks, Terry  :P

HIYA Craig that is my problem NOT near enough rocks to be fishing in LUA

LOOKS GOOD

(;-) TP

Offline Bodini

*
  •  216 216
    • View Profile
Re: Variables reading and writing
« Reply #24 on: May 17, 2014, 10:51:42 PM »
HIYA Craig, I have a #VAR report generator for MACH3 that does that trick. It sweeps through ALL the Var Numbers and reports ONLY the one that are > OR <  0

IT IS important that you check for values < AND > because some values are negative values.

Save the text file and send it to Notepad for viewing and printing.

I trick I use a lot when trying to find something in the VARs . I input a Value into a DRO that is easy to spot then I create the report and open in Notepad. THen do a search on that string to find the value and I then HAVE the Var number where I found the value.


Thnaks, (;-) TP

If I read you correctly, I made something like that last night for Mach 4.  Like you said, its good to seek out a certain number you are looking for with a search in notepad (i like notepad++, btw).  This script has similar concepts used in that tool table writing script.  I have it set to stop at 14000 because it sometimes doesnt work after that for reasons that are beyond my knowledge (as most things in this codey stuff are)  :D

-Nick

Code: [Select]
file = io.open("registry introspect.txt","w") -- open a new current file
file:write("Mach 4 Register Variables\n\n")
inst = mc.mcGetInstance()
regstart = 1  --start registry #
regend = 14000 --end registry #
regstep = 1  --step increment
rowno = regstart

for L1 = regstart,regend,regstep do  --creates the registry number to check
    v1 = mc.mcCntlGetPoundVar(inst, L1)  --gets the var from the registry number

    if v1 < -1000000 then
        --filters out big negative numbers
    elseif v1 > 1000000 then
        --filters out big positive numbers
    elseif v1 == 0 then
        --filters out zero values
    else
        l1output = string.format ("%5d = %10.4f \n",rowno,v1)  --formats registry var number for writing
        file:write(l1output)  --writes to file
 
end
    rowno = rowno + 1 --iterate the row number
end
file:write ("\n")  
file:write(os.date("Created: %x  %X"))
file:close()
[\code]

Offline BR549

*
  •  6,865 6,865
    • View Profile
Re: Variables reading and writing
« Reply #25 on: May 17, 2014, 11:22:38 PM »
HI ALL, trying to get the probe file open to work but no luck so far. the error message says the format is 
 
mcCntlProbeFileOpen(number, string, string, number");

The probing NOTES says this should work, but notta so far

mcCntlProbeFileOpen(inst, "myProbeFile.csv", "%.4AXIS_X, %.4AXIS_Y, %.4AXIS_Z");

Anyone played with this yet, ????
Re: Variables reading and writing
« Reply #26 on: May 18, 2014, 07:40:20 AM »
Nice job Nick, I'll try it out

Thought id post a text file on pound(#) variables  for another reference document

hell I thought that character was renamed "hash tag"  ;)


Terry: I did not have luck getting the information found in the Probe doc to write to a file, thou it did create the file just nothing was passed to it. Have to revisit and throw more rocks, as the more I understand whats up.
« Last Edit: May 18, 2014, 07:45:35 AM by Ya-Nvr-No »
Re: Variables reading and writing
« Reply #27 on: May 18, 2014, 08:34:53 AM »
found this worked to 15000 for me (at least I did not get any messages, so assume it works)

    if (v1 < -1000000 or v1 > 1000000) then
        --filters out big numbers
    elseif v1 ~= 0 then
        l1output = string.format ("%5d = %0.6f \n",rowno,v1)  --formats registry var number for writing
        file:write(l1output)  --writes to file
    else
    end

Thanks Nick ya did good. nice to have new tools.  ;D
« Last Edit: May 18, 2014, 08:45:00 AM by Ya-Nvr-No »

Offline BR549

*
  •  6,865 6,865
    • View Profile
Re: Variables reading and writing
« Reply #28 on: May 18, 2014, 02:58:13 PM »
HIYA Craigs Just a note there is no E #var, the Eword is reserved in mach4. Thanks for the list. I will add it to my Mach4 manual.

What code did you use to open and write the probe file ? An example would be nice in lua of me running LOW on rocks(;-).

Just a thought, (;-)TP
Re: Variables reading and writing
« Reply #29 on: May 18, 2014, 03:45:34 PM »
the list I got from Steve Murphree

the script was posted, not much to it. so ya don't need big rocks or many of them to paste the script in a button click.
You do have to set up the iRegs0 with the variable names, don't forget to restart Mach4 to initiate them.

http://www.machsupport.com/forum/index.php/topic,27256.msg192478.html#msg192478