Textmode Emulation on a WindowedScreen

Share your advanced PureBasic knowledge/code with the community.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

Thanks again for your interest and friendiness
you're welcome :D
The character that i want is a square green in background black.
Like the old computer IBM
look up the part in the code where the cursor is created. (sprite 256)
I draw two horizontal lines on it.
try drawing a box on it, and try different sizes and positions, until it fits your wish.
This screen is the viewer of a big and long code and it's not simple for me
what do you exactly want to display in this screen?
normally, today such a screen is just some Game surface or some Game element.
if you are writing an application, why don't you use a console?
oh... and have a nice day.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

if you are writing an application, why don't you use a console?
It's a long history but i try to do short ...

It's for my job, our principal tool is a big old computer IBM 3270.
For works on this very old pc, our use a emulator that works in a resolution screen of 80 X 30.
I want to emulate this screen, and make code around to pilot this emulator.

In one word, an emulator what emulate an emulator, it's simple, no !!!:lol: :lol:

This emulator is resizing, then, i want create the same screen of the original IBM emulator.
The console is not resizing, this is the reason of my choice. :wink:
ImageThe happiness is a road...
Not a destination
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

hm... so you use the 3270 PC, not the terminal at a mainframe?

what is the reason you want to use an emulator on a modern pc?
wouldn't a simple handshake-program be sufficent?

what is the I/O you have to embed?
if you have further information about it, I could help you more precisely on your problem.


one more point to the actual status...

if you want it resizable to make it cover the whole display,
you'd perhaps better open a fullscreen than using a resized windowedscreen.

do you have any photos/screenshots from the original 3270 charset?
would be nice to recreate it as original as possible...


PS:
this emulator?
oh... and have a nice day.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

PS:
this emulator?
Yes, it's exactly this screen.
It's attachmate EXTRA emulator.

I have not screenshot, and i'm sorry but i don't have the right to publish it, for confidentiality :cry:
what is the reason you want to use an emulator on a modern pc?
My enterprise is old and she can't change his hardware (Too expensive and too hard)
A emulator is installed for works many computer on his network
wouldn't a simple handshake-program be sufficent?
what is the I/O you have to embed?
My english is too bad, and i'm not an expert in network, i don't understand
ImageThe happiness is a road...
Not a destination
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

no problem, I thy to be more descriptive.

so far, I understood you have a mainframe like e.g. an AS400,
and you are using an terminal-emulator on your PCs to connect with.

so, if you want to embed this emulator into another surface,
you have to handle a lot of I/O (In and Out, Dataflow) between the new surface and the emulator.

now I ask myself, if it would be less work,
to handle the I/O to the mainframe/host directly and leave the old emulator away.


what is the Data your Emulator uses for communication?
if you want to embed it into a new surface,
you have to get output from it to display it on your screen,
and you have to get Input from your Display and send it to the emulator.

and there I think - why use the emulator in between?
if you already have to program a kind of terminal to communicate with the emulator,
why not write it that way that it communicates directly with the mainframe?

a Terminal is just an Input/Output handler for the host, not really a computer itself..
oh... and have a nice day.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

The problem is that i don't understood nothing at the protocol and language use by EXTRA emulator.
It's very hard to configured by a beginner like me :cry:

Of course, i dream to create a software like EXTRA, but how he works ??? :shock: i don't have any idea :oops:

I never see the big old computer.
They are in another city far away linked by the network.
On top of that, I have no approval to make whatever it is :cry:

My firm is really special and strict :cry: , thats all the reason :wink:
ImageThe happiness is a road...
Not a destination
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

the first problem is, that the terminal does not communicate in ASCII

take a look here:
http://www.wyse.com/products/winterm/qu ... cn17ab.htm
scroll down to about 70%, there comes the charset table of the 3270.
so, when you display the datasets sent by the Host or by the Terminal as text on a PC, you surely see nothing.

then you have to keep in mind, that the 3270 communicates via mask editing.
that means, all you edit you edit on the terminal.
only when you press the [SEND] key, the complete sheet is sent to the Host.

but that alone is not enough...
surely you'll need further information should get from your field-service or some operators.

why don't you get such information... don't they want you to write something?
if they ordered you to program something - why don't they provide information?

> My firm is really special and strict

even if you worked in the Secret Service...
when you are ordered to program, they should give you technical information.
oh... and have a nice day.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

even if you worked in the Secret Service...
when you are ordered to program, they should give you technical information.
You are right :D

It's a very special firm :?
There is a technical service which to install EXTRA in the computer.
After i program soft in purebasic or visual basic witch command EXTRA by the OLE automation.
I do not have the right to change any parameter of EXTRA, i have just the right to pilot it :cry:
ImageThe happiness is a road...
Not a destination
Grillmeister
New User
New User
Posts: 5
Joined: Sat Dec 13, 2008 1:20 pm
Location: Germany

Post by Grillmeister »

Hello Kaeru Gaman,

thank you for the code, it`s great.
Only one little problem:

If i lock the screen while the code is running, i will get an "invalid memory access" after unlocking the screen.
I tested it with Purebasic 4.20, 4.30beta5 under XP and Vista.

Do you have any idea why ?

Regards,
Grillmeister
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

an IMA? not some "specified output is Null"?

> If i lock the screen while the code is running

what exactly do you mean by locking the screen?


whatever the problem is, try to check the screen for active before displaying:

Code: Select all

  ;***************************************
  ;*** Screen Action start

  If IsScreenActive()
  
    ClearScreen($000000)    ; not really necessary, because we cover the screen with sprites...
      TxtScrn_Display()     ; display the textmatrix array on the screen
      TxtScrn_ShowCursor()  ; show our cursor
    FlipBuffers()

  EndIf

  ;*** Screen Action end
  ;*************************************** 
perhaps this already solves the problem.

anyhowe, please provide more info, describe your problem more detailed.
oh... and have a nice day.
Grillmeister
New User
New User
Posts: 5
Joined: Sat Dec 13, 2008 1:20 pm
Location: Germany

Post by Grillmeister »

Wow, thanks for the fast reply :)

By locking the screen i mean, i press Strg+Alt+Entf and then i lock the screen.
For example, i need to do this in my company when i will leave my office.

And yes, i get an IMA and not an "soiN" ;-)

I also tried to check the screen for active before displaying - without success.
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

ah I see...

I was a bit confused about the term "screen", because my code uses one.

I have no experience with locking the Desktop/User/Workstation,
so I don't know what it is actually doing under the hood.

I will give it some tests, perhaps I could catch a trace.

PS:
sorry, no IMA here, XPpro sp2, PB 4.20
can't catch a trace of no error...
oh... and have a nice day.
Grillmeister
New User
New User
Posts: 5
Joined: Sat Dec 13, 2008 1:20 pm
Location: Germany

Post by Grillmeister »

Sorry, one thing i forgot:

If i activate thread-safe executable under compiler options, i will get an IMA after lock/unlock the screen. I need thread-safe for my application.

If i deactivate thread-safe executable, i will not get an IMA after lock/unlock the screen, but then your code does not show letters anymore (only the cursor).

Same Problem on XPpro sp2, PB4.20 and Vista Home Premium sp1, PB4.20.

Strange... :shock:
User avatar
Kaeru Gaman
Addict
Addict
Posts: 4826
Joined: Sun Mar 19, 2006 1:57 pm
Location: Germany

Post by Kaeru Gaman »

I used the example code on page 1 and added the IsScreenActive()-check.
compiled without threadsafe.
when locking/unlocking the workstation, the program continues execution without any problem.

when I activate "threadsafe", the program will terminate when locking the workstation... strange.
no IMA or anything, but just disappear.


... maybe others have some ideas what to do.
as already said, I have no experience with locking the workstation.
some insite how it works in detail would be fine.

any hints anybody?
oh... and have a nice day.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

heres another text ouptut thing:

Code: Select all

global crtOut.s
global crtWdt, crtRows, crtHgt, crtMs 

crtWdt = 300
crtRows = 25
crtHgt = 20
crtMs = 25
#CRT = 1
global dim crtId(crtRows)


procedure openCRT(p)
  shared crtId()
  flags = #PB_WINDOW_SCREENCENTERED | #PB_WINDOW_BORDERLESS 
  openWindow(#CRT, 0, 0, crtWdt, crtRows * crtHgt, "OUTPUT", flags)
  stickyWindow(#CRT, 1)
  setWindowColor(#CRT, rgb(0, 0, 0)) 

  if createGadgetList(windowID(#CRT))
    font = loadFont(#PB_ANY, "courier new", 12, #PB_FONT_BOLD)
    setGadgetFont(#PB_DEFAULT, fontID(font))

    flags = #PB_STRING_READONLY ! #PB_STRING_BORDERLESS

    for i = 0 to crtRows - 1
      crtId(i) = stringGadget(#PB_ANY, 0, crtHgt * i, crtWdt, crtHgt, "", flags)
      setGadgetColor(crtId(i), #PB_GADGET_FRONTCOLOR, rgb(64, 255, 64))
      setGadgetColor(crtId(i), #PB_GADGET_BACKCOLOR, rgb(0, 0, 0))
    next i
  endIf

  repeat
    windowEvent()
  until crtOut = "close" 

  closeWindow(#CRT)
endProcedure 

procedure crtList(line.s)
  shared crtId()
  crtOut = line
  for id = 0 to crtRows - 2
    setGadgettext(crtId(id), getgadgettext(crtId(id + 1)))
  next id
  
  if crtOut = #CR$
    setGadgetText(crtId(id), "")
    procedureReturn
  endIf

  for col = 1 To len(crtOut)
    txt.s = left(crtOut, col)
     setGadgetText(crtId(id), txt + "_")
;    setGadgetText(crtId(id), txt + chr(449))
    delay(crtMs)
    windowevent()
  next col

  ;remove cursor
  delay(crtMs * 10)
  setGadgetText(crtId(id), crtOut)
endProcedure

flags = #PB_WINDOW_SYSTEMMENU ! #PB_WINDOW_MINIMIZE
openWindow(0, 0, 0, 300, 20, "MAIN WINDOW", flags)

;open output screen
createThread(@openCRT(), 0)  
delay(25)
 
;output messages
for i = 1 To 19
 crtList(right("0000" + str(i), 4) + mid(" asjka dk2 61 xyz dff dg", 1 , Random(24)))
 if (i % 10) = 0
   crtList(#CR$)
 endIf
next i
crtList(#CR$)
crtList("STOP")
    
repeat
until windowEvent() = #PB_EVENT_CLOSEWINDOW

crtOut = "close"
end
Post Reply